Repository navigation
Look up an incremental baseline by commit ancestry before branch names (v1.16.2) - #182
Conversation
Search the 20 nearest commits behind HEAD in batches of 10, nearest first, and take the scan of the closest commit, reading every page of a batch so a nearer commit's scan on a later page is not missed. Fall back to the branch being scanned, then trunk, only when none of those commits was scanned. Co-authored-by: ibrahim <ibrahim@corgea.com>
A shallow clone holds its boundary commit's parent ids but not the parents, so the commit lookup asks only about the commits the clone has, then falls back to the branch lookups. Covered with a real git clone --depth, and the no-baseline message no longer says 'the 1 most recent commits'. Co-authored-by: ibrahim <ibrahim@corgea.com>
corgea-security
left a comment
There was a problem hiding this comment.
Automated review risk: 2/5.
The baseline-selection change is coherent and well covered by focused tests. No actionable critical, high-priority, or non-blocking defects are supported by the supplied diff.
No critical or high-priority changes were found.
corgea-security
left a comment
There was a problem hiding this comment.
Approved by Dennis: high policy risk and automated risk 2/5.
There was a problem hiding this comment.
On a merge commit both parents are the same distance, and the newer one wins. Ancestry now runs before the branch lookup, so that newer parent becomes the baseline: the feature tip when landing on trunk, or trunk when a long-lived branch merges trunk in. The diff is the other line's work since the fork, and past the server's 300-file cap the run scans the whole tree. The first parent is the scan this order used to take.
Sent by Cursor Automation: pr-flow
| /// Order among scans found by ancestry, lowest best: fewest commits back, | ||
| /// then one this run can diff by its checksums over one it cannot. | ||
| fn ancestor_rank(&self, checksums_usable: bool) -> (usize, bool) { | ||
| let readable_checksums = self.manifest_root.is_some() | ||
| && self.manifest_version.as_deref() == Some(MANIFEST_VERSION); | ||
| ( | ||
| self.commits_back.unwrap_or(usize::MAX), | ||
| !(checksums_usable && readable_checksums), | ||
| ) | ||
| } |
There was a problem hiding this comment.
Both parents of a merge are the same distance. Ancestry::walk stores depth + 1 for every parent, and the_walk_follows_both_sides_of_a_merge_and_skips_other_branches asserts both are 1. This rank is (commits_back, without_checksums); nearest_ancestor_baseline then breaks the tie with page position, and the server lists newest first, so the newer parent wins.
plan_diff only calls find_baseline when this lookup returns NotFound, so the tie is the baseline whenever both parents were scanned. On a merge that is the second parent. The diff from it is every file the other line changed after the fork. The server full-scans above 300 (INCREMENTAL_SCAN_MAX_FILES, the comment on MAX_CHANGED_FILES). The diff from the first parent is the merge. Before this change the branch lookup returned that scan and never reached this rank.
is_usable_baseline drops a scan only when pull_request_id is set. A branch scan from this CLI leaves it empty, so the other side stays eligible. the_nearest_ancestor_scan_wins_whatever_branch_it_names only covers a strictly smaller commits_back.
Walk parent(0) into a set, capped at ANCESTOR_LOOKUP_COMMITS (a missing parent ends it, which is already where a shallow clone stops), and set on_first_parent on the BaselineScan built in nearest_ancestor_baseline. A second-parent scan is still the baseline when the first parent was never scanned. unbeatable at line 844 has to be this same triple, using that sha's own off-spine bit, so a checksum scan of HEAD still stops the page walk.
| /// Order among scans found by ancestry, lowest best: fewest commits back, | |
| /// then one this run can diff by its checksums over one it cannot. | |
| fn ancestor_rank(&self, checksums_usable: bool) -> (usize, bool) { | |
| let readable_checksums = self.manifest_root.is_some() | |
| && self.manifest_version.as_deref() == Some(MANIFEST_VERSION); | |
| ( | |
| self.commits_back.unwrap_or(usize::MAX), | |
| !(checksums_usable && readable_checksums), | |
| ) | |
| } | |
| /// Order among scans found by ancestry, lowest best: fewest commits back, | |
| /// then one on this checkout's first-parent line over the other side of a | |
| /// merge, then one this run can diff by its checksums over one it cannot. | |
| fn ancestor_rank(&self, checksums_usable: bool) -> (usize, usize, bool) { | |
| let readable_checksums = self.manifest_root.is_some() | |
| && self.manifest_version.as_deref() == Some(MANIFEST_VERSION); | |
| ( | |
| self.commits_back.unwrap_or(usize::MAX), | |
| usize::from(!self.on_first_parent), | |
| !(checksums_usable && readable_checksums), | |
| ) | |
| } |
The suggestion needs on_first_parent: bool on BaselineScan (false from from_response) and HashSet on the walk; it does not compile on its own. Add a unit test on the existing merge fixture: both parents scanned, the second parent's scan newer, the first parent returned.
Both parents of a merge sit one commit back, so recency decided between them and the merged-in side could win. Its diff is everything the first line did since the fork, which can outgrow an incremental scan; the diff from the first parent is the merge itself. Rank first-parent ancestors ahead at equal distance, and compute the page walk's early-stop rank over the whole batch. Co-authored-by: ibrahim <ibrahim@corgea.com>
Co-authored-by: ibrahim <ibrahim@corgea.com>


What
Changes the order
corgea scan blastuses to pick the baseline scan for an incremental scan.Before: the branch being scanned → the nearest of the last 10 commits → trunk (
origin/HEAD,main,master).After:
origin/HEAD,main,master). Same behavior as before, including the clean-only second walk per branch group.Why
A scan of a commit HEAD descends from differs from this upload by exactly what the history has done since. That makes it the most reliable baseline. A branch's newest scan can be of a commit this checkout is behind or was rebased away from. Trunk's newest scan also includes whatever trunk did after the branch forked.
Details
fetch-depth: 0.Tests
a_scan_beyond_the_first_ten_commits_is_found_by_the_second_batch.the_closest_commit_wins_even_when_its_scan_is_on_a_later_page.between_the_parents_of_a_merge_the_first_parent_wins, and extended the merge-walk test to check which commits are on the first-parent line.a_shallow_clone_offers_only_the_commits_it_holds, a unit test using a realgit clone --depth 1and--depth 2.a_shallow_clone_asks_about_the_commits_it_holds_then_falls_back_to_the_branch, an end-to-end run from a depth-1 clone, with and without stored checksums../harness checkpasses.