Add --max-reviews: cap reviews per loop, cut after the seeded shuffle - #35
Merged
Conversation
--max-reviews N caps how many reviews one loop runs, however large the expanded --reviews/set schedule is. The cut happens after the per-loop Fisher-Yates draw, which always shuffles the full list, so --seed replays exactly which N ran, every loop's draws match an uncapped run's, and different loops sample different reviews. A review scheduled twice fills two of the N slots when both land inside the cut. Stack mode never shuffles, so there the cap truncates cfg.Reviews itself in New: the single ordered pass runs its first N entries (at most N PRs), and the resume suffix check keeps indexing the same slice. A hot-reload resume queue is never re-capped: it is the already-truncated remainder of an interrupted loop, and it may legitimately exceed a cap that was raised between processes. The run-start and loop-start events carry the capped per-loop total, and --dry-run reports the cap on its count line (truncating the printed pass too in stack mode, where the order is known). 0 is unlimited and the default; negatives are a usage error; a cap at or above the schedule length changes nothing.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--max-reviews Ncaps how many reviews one loop runs, however large the expanded--reviews/set schedule is.0(the default) is unlimited, a negative value is a usage error, and a cap at or above the schedule length changes nothing.Where the cut happens. After the per-loop Fisher-Yates draw in
schedule(), which still shuffles the full list. Cutting before it would change the draw keys, so this order keeps--seedreplaying exactly which N ran, keeps every loop's draws identical to an uncapped run's, and lets different loops of one run sample different reviews. A review scheduled twice (weighting) fills two of the N slots when both land inside the cut — the flag help and docs say so.Stacked PRs. Stack mode never calls
schedule(); its one pass walkscfg.Reviewsin configured order and the resume suffix check indexes into that slice. The cap therefore truncatescfg.Reviewsitself inNew, so the pass runs its first N entries (at most N PRs) andstackResumeIndexstays consistent.Hot-reload resume. A
ResumeQueueis never re-capped: it is the already-truncated remainder of an interrupted loop, and may legitimately exceed a cap raised between processes. Pinned byTestMaxReviewsDoesNotRecapAResumeQueue.Reporting.
--dry-runprintsReviews per loop: 2 of 5, capped by --max-reviews(and, in stack mode, truncates the printed pass, whose order is known there). The run-start and loop-start events carry the capped per-loop total.Wiring. Registered in
flags.gomirroring--retries, validated infinishFlags, documented in theReviewshelp group anddocs/CLI.md, added togoldenFlagNamesand the CHANGELOG. Not in anysubcommandFlagsallowlist, sogauntlet runs --max-reviews 3is refused (test added).Tests. Truncation-after-shuffle determinism under a fixed seed, oversized cap as a no-op, resume queue not re-capped, stack-pass truncation, flag parsing/rejection rows, and dry-run output.
make ci(fmt/fix/vet + full race suite) is green, and the behaviors above were also exercised against the built binary.