Repository navigation
fix(review-guard): narrow entry cap and preserve PR verdict history across replacement PRs (CHE-11061) [squash] - #2295
Open
congvc-bot-x99[bot] wants to merge 5 commits into
Conversation
Author
|
Merge-Eligibility: REFUSED
|
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Dec 5, 2026
This branch has not been deployed
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.
Status
Draft PR for CHE-11061. Base:
mainata91aa3dce4e6418196b22d3df16cb8615e4b7fd6. Head:f4f39ff366fec96faf9fdc0bfd179b22af3d8900.Conditions
This PR targets
main. Keep this PR draft through independent review and required human final review.Why
Routine author revisions could exhaust the review entry cap and send an active issue to
need_decision. A replacement PR could also reset theCHANGESverdict count (CHE-11061). AfterCHE-11211narrowed round counting onmainto recordedreview_changes_requestedverdicts, replacement PRs still started at zero and repeatedCHANGESverdicts on one head were not deduplicated.What changed
CountChangesRoundsForPRwithCountChangesRoundsForReviewContext(server/pkg/db/queries/agent.sql,server/pkg/db/generated/agent.sql.go) soCHANGESverdicts count distinct reviewed heads across all PRs on an issue while preservingCHE-11211exclusion of mechanical handoff wakeups.HasChangesRoundForHeadand wiredguardChangesVerdict,reviewRoundsCapped,recordRoundsCapped, andrecordVerdict(server/internal/handler/review_loop_guard.go) to deduplicate repeatedCHANGESverdicts on the same head and resolve PR context across author and reviewer runs (reviewContextHasPR).server/internal/handler/review_loop_guard_test.go,server/internal/handler/review_round_cap_test.go,server/internal/handler/review_verdict_resolve_test.go), and formattedserver/internal/handler/review_round_cap.gowithgofmt.stateDiagram-v2 state "In progress" as Work state "Agent review" as Review state "Blocked" as Blocked state "Need decision" as Decision Work --> Review: author submits a revision; ordinary entry is not capped Blocked --> Review: mechanical retry does not count as CHANGES Review --> Work: CHANGES on a distinct head; count spans replacement PRs Review --> Review: reviewer wakeup; recorded without consuming CHANGES limit Review --> Decision: 3rd distinct-head CHANGES verdict reachedScope
Covers
CHE-11061Step 1: review-loop entry cap reconciliation withCHE-11211, replacement-PR verdict history preservation, and distinct-head deduplication without adding a third counter. Leaves downstream auto-split and arbiter steps to their dedicated follow-up issues.Tradeoffs
Keeping the counter scoped to a single PR is simpler, but closing and opening a replacement PR resets verdict history to zero. Counting distinct
head_shavalues across linked PRs preserves the three-round bound while preventing duplicate verdicts on one head from burning rounds.Blast Radius
The handler guard (
server/internal/handler/review_loop_guard.go) and SQL queries (server/pkg/db/queries/agent.sql) govern issue review transitions. A counting regression would either open premature decision cards or let repeated distinct-head rejections exceed three rounds. On parent commit78fe52ba10a23ef9610b5d6a04647ce5d312ffa2, forty-six targeted handler integration tests ran against PostgreSQL (PASS, 0 failed). Headf4f39ff366fec96faf9fdc0bfd179b22af3d8900removes two blank lines inserver/internal/handler/review_round_cap.go(gofmt -landgit diff --checkexited 0, while local PostgreSQL tests were NOT-RUN onf4f39ff366fec96faf9fdc0bfd179b22af3d8900because another test run held the shared test database). Proof level: 1 (read-only +gofmton exact headf4f39ff366fec96faf9fdc0bfd179b22af3d8900, with integration proof level 3 observed on AST-identical parent78fe52ba10a23ef9610b5d6a04647ce5d312ffa2).Verification
78fe52ba10a23ef9610b5d6a04647ce5d312ffa2:cd server && GOMEMLIMIT=2800MiB GOMAXPROCS=2 GOGC=50 go test -c -p 1 -o ../handler.test ./internal/handler && cd internal/handler && ../../../handler.test -test.v -test.count=1 -test.run 'Test(RoundCap|ReviewLoop|VerdictResolve)'Result:
PASS(46 top-level tests passed, 0 failed, includingTestRoundCap_FourOrdinaryEntriesDoNotTripRecoveryBound,TestRoundCap_BlockedReviewEntriesDoNotCountAsChanges,TestRoundCap_ReplacementPRDoesNotResetRounds,TestRoundCap_FourthEntryWithLinkedPRReplacementHistoryGoesToNeedDecision,TestReviewLoop_ThreeDistinctHeadsAcrossReplacementPRsGoToNeedDecision,TestReviewLoop_RepeatedChangesHeadDoesNotConsumeDistinctHeadLimit,TestReviewLoop_RepeatedCurrentChangesHeadDoesNotConsumeLimit, andTestVerdictResolve_ThreeEntriesLeavingThroughBlockedDoNotCapTheFourth).78fe52ba10a23ef9610b5d6a04647ce5d312ffa2(run47556134693):backend-test-shards(handler-0,handler-1,handler-2,handler-3,service,rest),e2e,decision-card-e2e,sqlc-check, andmigration-checkspassed, failing onlygo-lint(gofmtonserver/internal/handler/review_round_cap.go:37:1).f4f39ff366fec96faf9fdc0bfd179b22af3d8900:gofmt -l server/internal/handler/review_loop_guard.go server/internal/handler/review_loop_guard_test.go server/internal/handler/review_round_cap.go server/internal/handler/review_round_cap_test.go server/internal/handler/review_verdict_resolve_test.go server/pkg/db/generated/agent.sql.goandgit diff --checkexited 0 with empty output.Changelog
Changelog: Routine review iterations and replacement PRs now track distinct reviewed heads accurately.
Type of Change
Changes Made
CountChangesRoundsForPRwithCountChangesRoundsForReviewContextand addedHasChangesRoundForHeadinserver/pkg/db/queries/agent.sqlandserver/pkg/db/generated/agent.sql.go.guardChangesVerdict,reviewRoundsCapped,recordRoundsCapped, andrecordVerdictinserver/internal/handler/review_loop_guard.goandserver/internal/handler/review_round_cap.go.server/internal/handler/review_loop_guard_test.go,server/internal/handler/review_round_cap_test.go, andserver/internal/handler/review_verdict_resolve_test.go.How to Test
cd server && go test ./internal/handler -run 'Test(RoundCap|ReviewLoop|VerdictResolve)' -count=1against a migrated PostgreSQL test database.Patterns
Agent-facing
Agent-facing: no
Cost delta
need_decisionstalls from repeated-head verdicts while capping replacement-PR loops at 3 distinct heads. Measured via daily decision-card and run-usage reports.activity_logrows without adding a third counter or extra tables.review_rounds_cappedevents after merge. Investigate if routine revisions open cap cards or if replacement-PR loops exceed 3 distinct heads.Related Issue
Closes CHE-11061