Skip to content

reviewer: Skip the review of an unchanged patch that reviewed clean - #873

Merged
rgushchin merged 10 commits into
sashiko-dev:mainfrom
chucklever:skip-unchanged-clean
Nov 12, 2026
Merged

rgushchin merged 10 commits into
sashiko-dev:mainfrom
chucklever:skip-unchanged-clean

Conversation

@chucklever

@chucklever chucklever commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Large series are being resent with very sparse changes. A RESEND or
a v+1 of a 49-patch series that touches a handful of patches is
reviewed again in full, and every unchanged patch that reviewed clean
the first time comes back clean at the same price. On our instance a
few such resends in a short span ran up a significant bill for almost
no new information.

This series lets a patch inherit a clean verdict instead. With
[review] skip_unchanged_clean set, a patch whose diff matches an
earlier patch that a model reviewed to completion with no findings
gets a Skipped review row naming that review, and no model run. It is
off by default. On the resend pair that prompted the work, 30 of 49
patches inherited and the series cost roughly half of a full review.

The design document comes first and the last commit brings it in line
with what was built; section 5.3 lists the conditions and section 6
the risks. The decisions worth checking:

Identity is the diff, not lineage. patches.git_patch_id is already
computed and indexed, so it narrows the search, and the diffs are then
compared line for line with only the mail header, index lines, and
hunk line ranges ignored. A patch moved between series or resent under
a new thread matches. Because lineage is not consulted, the lookup
itself refuses a reviewed copy that drew a reply from anyone but
Sashiko; the prior-feedback audit would not otherwise see it.

Only a verdict at least as strong is inherited. The newest review of a
diff overrules older clean ones. The model and prompt hash must match
unless skip_unchanged_clean_any_model is set. A review.cheap or
--stages review is inherited only by a review narrowed the same way,
which needs two new columns since neither changes the model or the
prompt hash. A rerun always gets a model run.

The tree is allowed to drift by default. A repost nearly always lands
on a newer tip and often changes an earlier patch of the series, so
requiring the same tree would skip almost nothing.
skip_unchanged_clean_require_same_baseline turns that requirement on,
for the baseline commit and for the patches ahead in the series, and
skip_unchanged_clean_max_age_days (90) bounds the drift otherwise.

An inherited verdict counts as one finished review, so a fully
inherited series is clean and leaves its embargo. It queues the
Patchwork check a clean model review would and no mail. Behind an
embargo the patch reads as Embargoed.

One commit fixes a defect the series depends on but did not cause.
Since 9351acd the early release of a clean embargoed patchset
passes a row whose status still reads In Review, so nothing held back
is queued before the embargo is cleared. That commit stands alone and
carries a Fixes: trailer.

The schema change is migration 22: four nullable or defaulted columns
on reviews and one index.

Verified on 5e284b6: check-pr passes with 1730 unit and 88
integration tests.

@sashiko-bot

sashiko-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

Sashiko review

Commit 5/9 — b83e880d db: Look up completed reviews of a patch's earlier copies

  • [MEDIUM] src/db/prior_context_queries.rs:
    Database::patch_has_human_replies() queries only direct replies in messages
    via query_replies_to() and treats any non-Sashiko row as human discussion.
    Because ingested patches and cover letters also live in messages with their
    In-Reply-To headers, coverless series where patches 2..N reply to patch 1,
    --chain-reply-to series, and revisions sent --in-reply-to an earlier patch
    match as human replies and block clean-review reuse. Conversely, when
    Sashiko replies to a patch mail and a human replies to Sashiko's message,
    patch_has_human_replies() ignores the direct Sashiko reply without checking
    its children and returns false. Exclude patch and cover-letter message IDs
    as find_foreign_patchset_barriers() does, and walk replies beneath direct
    Sashiko messages.

Commit 7/9 — 90c37afb reviewer: Inherit a clean verdict for an unchanged patch

  • [HIGH] src/reviewer.rs: when an embargoed patchset finishes cleanly in
    Reviewer::review_patchset_task(), it updates the database status to
    Reviewed and calls release_patchset_results() with the local PatchsetRow
    whose in-memory status is still In Review from process_pending_patchsets().
    Reviewer::queue_patchset_notifications() checks patchset.status ==
    Some("Reviewed") before running get_completed_reviews_for_release() and
    get_inherited_clean_patches(), so it skips queueing all held-back
    notifications and inherited Patchwork checks and then clears embargo_until
    in the database. Update patchset.status to Reviewed on the local struct
    before calling release_patchset_results().

  • [MEDIUM] src/db.rs: Database::get_inherited_clean_patches() runs on the
    shared read connection self.conn without acquiring self.tx_lock, unlike
    Database::query_completed_reviews_for_release() right below it. On
    file-backed SQLite, an open read cursor on self.conn pins it to an older
    WAL snapshot, so queue_patchset_notifications() can miss newly committed
    inherited Skipped reviews and drop their Patchwork checks before clearing
    the embargo, or miss a newly committed Reviewed row on a rerun and
    overwrite its check with an inherited success state. Acquire self.tx_lock
    (when not in a transaction) and query self.tx_conn instead.

  • [LOW] src/db.rs: Database::reset_patchset_review_state() and
    Database::delete_aborted_review_children_in_tx() preserve pending
    patchwork_outbox rows only when a patch has a review with status =
    'Reviewed'. If a patch inherited a clean verdict on pass 1 (status =
    'Skipped' with inherited_from_review_id IS NOT NULL) and a later rerun
    attempt aborts or fails while pass 1's Patchwork check is still pending,
    the cleanup deletes that pending check without a replacement. Treat a
    Skipped review with inherited_from_review_id IS NOT NULL as a completed
    pass in both NOT EXISTS clauses.

Full review and stage logs on sashiko.sashiko.dev

@chucklever

Copy link
Copy Markdown
Contributor Author

All four findings are valid and fixed in the force-push; the branch is
now ten commits.

High, embargo release with a stale status. Confirmed, and it
predates this series: 9351acd made queue_patchset_notifications()
queue only for a Reviewed patchset, while the early clean release in
review_patchset_task() still passes the row it was handed at claim
time, which reads In Review. Every clean embargoed patchset loses its
positive-review mail and Patchwork check, inherited or not. Fixed in a
commit of its own ahead of the reviewer change, with a Fixes: trailer:
"reviewer: Queue held-back mail when a clean patchset leaves its
embargo". It has no test; the call sits at the end of
review_patchset_task().

Medium, patch_has_human_replies(). Both halves fixed in commit 5.
A reply that is itself a patch or a cover letter is skipped, using the
same two lookups as find_foreign_patchset_barriers(), so a series
threaded under its first patch and a version sent in reply to an
earlier one no longer block reuse. The walk now continues beneath
Sashiko's own replies, so an answer to its review counts. The test
covers a threaded patch and a reply to the bot.

Medium, get_inherited_clean_patches() on the read connection.
Fixed: it takes tx_lock and reads tx_conn, as
query_completed_reviews_for_release() does.

Low, rerun cleanup deleting a pending inherited check. Fixed in
commit 6: both patchwork_outbox NOT EXISTS clauses, in
reset_patchset_review_state() and
delete_aborted_review_children_in_tx(), treat a Skipped row with
inherited_from_review_id as a completed pass. The new
test_rerun_keeps_inherited_patchwork_check fails without the change.

check-pr passes on 5e284b6 with 1730 unit and 88 integration
tests.

@sashiko-bot

sashiko-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

Sashiko review — v2

Commit 8/10 — 8be17609 reviewer: Inherit a clean verdict for an unchanged patch

  • [MEDIUM] src/reviewer.rs: Reviewer::find_inherited_clean_review() only calls
    patch_has_human_replies() on the original Reviewed candidate's message ID,
    because Database::find_clean_review_candidates() in src/db.rs filters out
    Skipped rows where inherited_from_review_id is set. When v1 is reviewed
    clean, v2 inherits that verdict and receives human replies on the list, and
    v3 is later sent in a new thread without patchset lineage to v2, v3 skips
    model review and ignores the replies on v2. Check for human replies across
    all patches that inherited from the candidate review as well.

Full review and stage logs on sashiko.sashiko.dev

@chucklever

Copy link
Copy Markdown
Contributor Author

The v2 finding is valid and fixed in the force-push.

find_inherited_clean_review() asked about replies to the reviewed
copy only. Reviews that inherited a verdict are left out of the
candidate list on purpose, so a reply to an inheriting copy was never
seen: v1 reviews clean, v2 inherits and draws the criticism, and a v3
with no lineage to v2 lands on v1's review again.

The lookup now also asks about every copy that already inherited the
candidate's verdict. Database::get_inheriting_patch_message_ids()
lists them (commit 5), and the reviewer runs patch_has_human_replies()
over the reviewed copy and each of those (commit 8).
test_unchanged_clean_patch_inherits_prior_review gains the v1/v2/v3
case: v3 inherits from v1, someone replies to v2, and v3 is then
refused.

check-pr passes with 1730 unit and 88 integration tests.

@sashiko-bot

sashiko-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

Sashiko review — v3

Commit 3/10 — a5101225 prior_context: Expose the unchanged-diff test as a predicate

  • [LOW] src/prior_context.rs: patch_diffs_equivalent() checks for emptiness
    before calling normalize_patch_diff_lines(), not after. When two non-empty
    inputs normalize to zero lines (for example, diffs with only index lines,
    or unified diffs without a line-leading diff --git header that mention
    diff --git mid-line), normalize_patch_diff_lines() returns empty vectors
    for both and patch_diffs_equivalent() returns true. Check !a.is_empty()
    after normalization.

Full review and stage logs on sashiko.sashiko.dev

@chucklever

Copy link
Copy Markdown
Contributor Author

The v3 finding is valid and fixed in the force-push (commit 3).

patch_diffs_equivalent() tested its inputs for emptiness before
normalizing them, so two bodies that normalize to no lines compared
equal: zero lines on each side and nothing to disagree. It now tests
after normalize_patch_diff_lines(). The test covers both shapes named
in the review, a body of index lines only and one whose only
"diff --git" is mid-line.

In the daemon the lookup is keyed on git_patch_id first, so two such
bodies would also have needed a shared patch ID to reach the
comparison. The predicate is wrong on its own terms all the same.

check-pr passes with 1730 unit and 88 integration tests.

@sashiko-bot

sashiko-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

Sashiko review — v4

Commit 3/10 — 1ad9d909 prior_context: Expose the unchanged-diff test as a predicate

  • [LOW] src/prior_context.rs: patch_diffs_equivalent() delegates to
    normalize_patch_diff_lines(), which sets started = true whenever the input
    does not contain "diff --git ". As a result, two identical mail-only or
    whitespace-only strings that do not mention "diff --git " retain all of
    their lines and patch_diffs_equivalent() returns true instead of false.
    Require a line starting with "diff --git " before collecting lines in
    patch_diffs_equivalent().

Full review and stage logs on sashiko.sashiko.dev

@chucklever

Copy link
Copy Markdown
Contributor Author

The v4 finding is valid and fixed in the force-push (commit 3). The
whitespace-only half of it was a regression from the v3 fix, which
dropped the trim() test in favor of one made after normalizing.

normalize_patch_diff_lines() treats a body with no "diff --git " as
raw diff text and keeps every line, so two identical bodies of mail
text or blank lines compared equal. patch_diffs_equivalent() now
requires the normalized body to begin with a line that opens with the
header. That one test covers every shape raised so far: no header at
all (every line kept, the first is not a header), a header mentioned
only mid-line (nothing kept), and index lines only (nothing kept).

The test adds mail text, a whitespace-only body, and a hunk that lost
its header. A patch produced by plain diff -u, with no git header, now
never matches; it is reviewed in full, as before this series.

check-pr passes with 1730 unit and 88 integration tests.

@sashiko-bot

sashiko-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

Sashiko review — v5

✓ No issues found across 10 commits.

Full review log on sashiko.sashiko.dev

Large series are reposted many times with changes to only a few
patches. The daemon deduplicates a patch only by message_id, so every
repost of an unchanged patch is a new review at full token cost, even
when the previous review of the identical diff found nothing. The
prior-version context already recognizes the unchanged diff but only
tells the model about it; the workflow still runs every stage.

Describe an opt-in skip: hash the normalized diff on each patch, and
when a completed review of the same hash exists with no findings,
record an inherited review row instead of running the model. The
document fixes the match conditions (model, prompts, baseline, age),
what the skip leaves behind for the dashboard and outbox, and the
risks of propagating a false negative.

Suggested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <cel@kernel.org>
A review that inherits its verdict from an earlier review of the same
diff needs somewhere to record which review that was, and comparing two
reviews by baseline needs the commit each one ran against. The
baselines table cannot supply the latter: last_known_commit moves with
every sync, so a review's baseline_id names a branch, not a tree.

A clean verdict is also only as strong as the review behind it.
review.cheap and --stages both narrow a review without changing its
model or prompt hash, so nothing on the row tells a narrowed review
from a full one.

Add inherited_from_review_id, baseline_commit, cheap, and stages to
reviews as schema version 22. cheap and stages default to a full
review, which is what every review older than the columns was unless
its operator narrowed it. The migration checks for the first column
before adding any, so a rewound user_version on an already migrated
database does not fail on the duplicate ALTER TABLE.

Suggested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <cel@kernel.org>
Deciding whether a reposted patch carries the same change as an earlier
one is already done here, inside compute_inter_version_diff, which
returns a sentinel string when the normalized diffs match. A caller that
only wants the yes-or-no answer has to compare against that string.

Add patch_diffs_equivalent, which applies the same normalization (drop
the mail header and the index lines, keep every diff line byte for
byte) and additionally ignores the line ranges on hunk headers: a
rebase onto a tree where earlier code grew or shrank rewrites
"@@ -269,15 +267,13 @@" without touching the hunk, and the function
context after the ranges still has to match. Whitespace stays
significant on purpose: git patch-id ignores it, and a reindented hunk
is a different patch. A body with no "diff --git" header matches
nothing, itself included, so mail text with no diff in it is never
taken for a change.

Suggested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <cel@kernel.org>
Reposted series change a handful of patches and carry the rest
unchanged, and every unchanged patch is reviewed again at full cost even
when its previous review found nothing. The reviewer is about to learn
to reuse such a verdict, and the operator needs to opt in and bound it.

Add four keys to [review]: skip_unchanged_clean turns the reuse on,
skip_unchanged_clean_max_age_days bounds how old a reused review may be,
skip_unchanged_clean_any_model allows reuse across a model or prompt
change, and skip_unchanged_clean_require_same_baseline restricts reuse
to reviews that ran on the same tree, meaning the same baseline commit
under the same earlier patches of the series. Only the age bound has a
non-zero default; the baseline check is off because a repost nearly
always lands on a newer tip, so requiring the same tree would skip
almost nothing.

Suggested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <cel@kernel.org>
Reusing a clean verdict needs the completed reviews of every other
patch that carries the same change, newest first, with a mark on the
ones that found something: an older clean verdict is only worth
reusing when nothing newer disagreed with it. The patches table already
indexes git_patch_id, which the ingest path computes for each patch, so
that column serves as the lookup key. It cannot be the identity,
because git patch-id ignores whitespace; the caller compares the
returned diff before trusting a match.

Add find_clean_review_candidates, which returns those reviews with the
diff, model, prompt hash, baseline commit, coverage, and a has_findings
flag the caller needs to decide, and leaves out reviews that themselves
inherited a verdict so the chain always ends at a review a model
produced. Add the writers for the new columns and a reader for a
patch's git_patch_id.

Coverage is a ReviewCoverage, built from review.cheap and the --stages
list. Its covers() test is one-way. A full review covers a cheap one
and any stage subset, and a narrowed review covers only a review
narrowed the same way.

Add patch_has_human_replies as well. The prior-feedback audit finds
replies to an earlier version through patchset lineage, and this
lookup matches patches that have none, so the caller needs to ask
about one patch mail directly. A reply that is itself a patch or a
cover letter does not count, or a series threaded under its first
patch would never match. The walk goes on beneath Sashiko's own
reply, because an answer to that review is discussion of the patch.
get_inheriting_patch_message_ids names the copies that already
inherited a review's verdict, so the caller can ask about them too.

Suggested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <cel@kernel.org>
A patchset is clean, and an embargoed one releasable early, only when
at least one of its reviews has status Reviewed and every patch either
reached its review count or was skipped for touching ignored files. The
retry accounting in the reviewer counts Reviewed rows the same way. A
patch that inherits a clean verdict from an earlier identical copy
leaves a Skipped row instead, so a reposted series whose every patch
inherited would sit as Incomplete and stay behind its embargo timer,
and a retry of the series would not see that the patch was handled.

Let a Skipped review with inherited_from_review_id set count as one
finished review in count_successful_reviews, CLEAN_PATCHSET_PREDICATE,
and get_patchset_review_outcome. Counting it, rather than exempting
the patch as the ignored-files skip does, keeps a rerun honest: the
rerun raises the target to two, the inherited row supplies one, and
the model runs exactly once more. The status is part of the test so a
row that failed after the provenance was written proves nothing.

Reclaiming a Pending row for a fresh model run clears the provenance
columns, so a review the model then produces is never mistaken for an
inherited one and excluded from later lookups. The same statement puts
the coverage columns back at a full review, so the row never carries
the coverage of a run that was given up.

The patch list of an embargoed patchset shows a Reviewed patch as
Embargoed. Show an inherited one the same way, or its Skipped status
tells a viewer which patches of the series came out clean.

The cleanup of an abandoned attempt deletes a patch's unsent
Patchwork check unless the patch has a Reviewed row. Spare the check
of a patch whose finished pass is an inherited one as well.

Suggested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <cel@kernel.org>
A patchset that finishes with no findings is released from its
embargo at once. review_patchset_task() writes the Reviewed status
and then calls release_patchset_results() with the PatchsetRow it was
handed when the review was claimed, whose status still reads In
Review. queue_patchset_notifications() queues the held-back
notifications only for a Reviewed patchset, so it queues nothing and
then clears the embargo. The positive-review mail and the Patchwork
check of every clean embargoed patchset are lost.

Hand the release a copy of the row carrying the status that was just
written.

Fixes: 9351acd ("db, reviewer: restrict Failed patchset embargo release to forge PRs")
Signed-off-by: Chuck Lever <cel@kernel.org>
A reposted series carries most of its patches unchanged, and the worker
reviews each of them again at full cost even when the identical diff
was already reviewed with no findings. The prior-version context tells
the model the diff is unchanged, but every stage still runs.

When [review] skip_unchanged_clean is set, look up the completed
reviews of other patches with the same Git patch ID, newest first, and
take the first whose diff matches byte for byte outside the index
lines. If that newest review found something, no older clean verdict
is reused. If it was clean, record a Skipped review that names it in
inherited_from_review_id instead of running the model. A review that
inherited its verdict is never itself a source, so a chain of reposts
always points back at the review a model produced.

A clean source is not enough on its own. It must match the model and
prompt set unless skip_unchanged_clean_any_model is set. It must have
run at least the pipeline this review would, so a review.cheap or
--stages review is inherited only by a review narrowed the same way,
and no setting waives that. Nobody but Sashiko may have replied to
the reviewed copy or to a copy that already inherited its verdict:
the lookup ignores lineage, so a patch criticized on the list and
resent under a new thread would otherwise slip past the
prior-feedback audit. With
skip_unchanged_clean_require_same_baseline set, the baseline commit
must match and so must the patches ahead of this one in the series,
because a rewritten 1/5 changes what an untouched 3/5 applies to.

The shortcut also stands down for work that needs a model run. A
rerun raises the patchset's target review count, and the skip is off
whenever that count is above one. A patch whose prior-version context
carries findings or human discussion is reviewed in full, and so is
every patch of a series whose context could not be built.

An inherited patch queues no mail. It does queue the Patchwork check
a clean model review would, since Patchwork otherwise shows no Sashiko
result for it. The check is held back by an embargo and sent on
release. A retry of an interrupted series stops at the inherited row
the way it stops at a Reviewed one, queues the check if the first
attempt did not, and leaves the patch Skipped.

Every normal review now records the commit its worktree was checked
out at. A cheap or stage-limited review also records its coverage,
and its model run waits for that write: the columns default to a full
review, so a narrowed run that failed to record itself would later
lend its verdict to a full one.

Suggested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <cel@kernel.org>
The patch list and the patch pane both print a bare "Skipped" for a
patch the worker did not review, even when the Skipped review row says
why. With clean-review reuse the reason names the review the verdict
was inherited from, which is the one thing a maintainer looking at the
patch needs.

Put the review's result text in the list entry's tooltip and in the
pane's placeholder, falling back to the bare word when no review row
carries a reason.

Suggested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <cel@kernel.org>
The design proposed a new patches.diff_hash column with its own index
and a lazy backfill. Implementation found that patches.git_patch_id,
computed at ingest and indexed since migration 12, already narrows the
search; one exact diff comparison per candidate turns it into the
identity the design wanted, so the column and the backfill were
dropped. The skip also follows the existing ignored-files path, which
leaves a Skipped review row and no outbox entry, rather than the
Reviewed row and outbox entry the draft described.

Self-review of the first implementation added three invariants the
draft lacked: the newest review of a diff overrules older clean ones,
a rerun's raised review count disables the skip, and a patch whose
prior-version context needs the prior-feedback audit is reviewed in
full. The clean-patchset predicate and the review outcome also had to
learn the inherited row, or a fully inherited series would never leave
its embargo.

Two skip conditions are new. One covers review.cheap and --stages,
which narrow a review without changing its model or prompt hash. The
other refuses a reviewed copy that drew a reply, which lineage-free
matching would otherwise hide from the prior-feedback audit. The
same-baseline rule now extends to the patches ahead of this one in
the series, an inherited patch posts a Patchwork check, and the risks
section names what the model and prompt check does not see.

Rewrite the identity, lookup, conditions, skip-outcome, observability,
and steps sections to say what was built, and record the dropped
column under the alternatives.

Suggested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <cel@kernel.org>
@rgushchin
rgushchin force-pushed the skip-unchanged-clean branch from bb93bf3 to 99bb43c Compare November 12, 2026 00:05
@rgushchin
rgushchin merged commit d80a35d into sashiko-dev:main Nov 12, 2026
1 check passed
@sashiko-bot

sashiko-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

Sashiko review — v6

✓ No issues found across 10 commits.

Full review log on sashiko.sashiko.dev

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants