Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-review-pending-fix-ttl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `review.pending_fix_ttl` sets how long a dispatched review fix may go without a new head before the next bounded attempt is dispatched (default 2h; negative disables expiry). It was previously fixed at 2h even though the docs presented it as tunable (#14643).
1 change: 1 addition & 0 deletions src/cmd/hive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10750,6 +10750,7 @@ func planReviewDispatchWith(ctx context.Context, cfg *config.Config, actionable
ReviseRepos: cfg.Review.ReviseRepos,
ReviseVerdictsBefore: parseReviseCutoff(cfg.Review.ReviseVerdictsBefore, logger),
PendingTTL: cfg.Review.PendingReviewTTL(),
PendingFixTTL: cfg.Review.PendingReviewFixTTL(),
MaxRedispatch: cfg.Review.EffectiveMaxRedispatch(),
HeadMaxRetries: cfg.Review.HeadMaxRetries,
ProjectOrg: cfg.Project.Org,
Expand Down
2 changes: 1 addition & 1 deletion src/docs/labels-and-control-signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ does not bump itself.
keeps an adopted PR in the fixer's work list every cycle until a new head
lands. Existing pending fix rows are replaced with the next bounded attempt
(adopted PRs at once; any other hive-owned PR once the row is older than
`PendingFixTTL`, default 2h, with the head unchanged);
`review.pending_fix_ttl`, default 2h, with the head unchanged);
once the attempt cap is exhausted the PR is visibly parked for a human at
085 with reason `fix-attempts-exhausted`, not left silent.
- **Cleared at once on any activity.** The next cycle that sees a new head,
Expand Down
1 change: 1 addition & 0 deletions src/docs/review-swarm.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ review:
base_sync: false # optional; let GitHub update-branch unstick hive-authored fork PRs (default off)
priority_labels: false # optional; mirror the PR review queue rank onto review-priority/* labels (default off)
pending_ttl: 45m # optional; re-dispatch a review that has posted no verdict after this long (default 45m)
pending_fix_ttl: 2h # optional; dispatch the next bounded fix attempt when a fixer has pushed no new head after this long (default 2h; negative disables expiry)
max_redispatch: 3 # optional; expiries per head before the PR is held for a human (default 3)
bot_author_model: "" # optional; model (or backend/model) that reviews PRs opened by bot_authors, e.g. gpt-6-luna (default empty = off)
bot_authors: [dependabot[bot], renovate[bot], github-actions[bot], "*[bot]"] # optional; logins routed to bot_author_model; the hive's own App never matches
Expand Down
3 changes: 3 additions & 0 deletions src/hive.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,9 @@ governor:
# fixer_agent: "" # optional override; defaults to the PR lane, then scanner
# pending_ttl: 45m # re-dispatch a review whose kick posted no verdict after this long
# # (Go duration; default 45m; negative disables expiry)
# pending_fix_ttl: 2h # dispatch the next bounded fix attempt when a fixer turn has
# # pushed no new head after this long (Go duration; default 2h;
# # negative disables expiry)
# max_redispatch: 3 # expiries per PR head before the planner stops re-kicking and
# # records a requires_human hold (review-dispatch-exhausted)
# out_of_scope_backlog_disabled: false # true opts out of review-filed backlog issues
Expand Down
6 changes: 6 additions & 0 deletions src/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7383,6 +7383,12 @@ type ReviewConfig struct {
// (hivecommons/hive#12045). "0" or unset means the default; a negative
// value disables expiry.
PendingTTL string `yaml:"pending_ttl,omitempty" json:"pending_ttl,omitempty"`
// PendingFixTTL is how long a dispatched review fix may go without a new
// head before its pending row expires and the next bounded attempt is
// dispatched (Go duration string, default DefaultPendingFixTTL;
// hivecommons/hive#14604). "0" or unset means the default; a negative
// value disables expiry.
PendingFixTTL string `yaml:"pending_fix_ttl,omitempty" json:"pending_fix_ttl,omitempty"`
// MaxRedispatch caps how many times one PR head's pending reviews may
// expire before the planner stops re-kicking and records a requires_human
// hold (reason prefix review-dispatch-exhausted). 0 means
Expand Down
31 changes: 31 additions & 0 deletions src/pkg/config/review_dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const (
// DefaultPendingReviewTTL matches review.DefaultPendingReviewTTL;
// duplicated here to avoid a config→review import cycle.
DefaultPendingReviewTTL = 45 * time.Minute
// DefaultPendingFixTTL matches review.DefaultPendingFixTTL; duplicated
// here for the same reason.
DefaultPendingFixTTL = 2 * time.Hour
// DefaultMaxRedispatch matches review.DefaultMaxRedispatch.
DefaultMaxRedispatch = 3
ReviewSelfAuthoredDecisionResolve = "resolve"
Expand Down Expand Up @@ -70,6 +73,21 @@ func (r ReviewConfig) PendingReviewTTL() time.Duration {
return d
}

// PendingReviewFixTTL is review.pending_fix_ttl as a duration. Unset, "0" or
// an unparsable value means DefaultPendingFixTTL; a negative duration is
// returned as-is and the planner reads it as "never expire".
func (r ReviewConfig) PendingReviewFixTTL() time.Duration {
raw := strings.TrimSpace(r.PendingFixTTL)
if raw == "" {
return DefaultPendingFixTTL
}
d, err := time.ParseDuration(raw)
if err != nil || d == 0 {
return DefaultPendingFixTTL
}
return d
}

// EffectiveMaxRedispatch resolves review.max_redispatch.
func (r ReviewConfig) EffectiveMaxRedispatch() int {
if r.MaxRedispatch <= 0 {
Expand Down Expand Up @@ -98,6 +116,19 @@ func (r ReviewConfig) ValidatePendingReviewTTL() error {
return nil
}

// ValidatePendingFixTTL rejects a review.pending_fix_ttl that is not a Go
// duration string.
func (r ReviewConfig) ValidatePendingFixTTL() error {
raw := strings.TrimSpace(r.PendingFixTTL)
if raw == "" {
return nil
}
if _, err := time.ParseDuration(raw); err != nil {
return fmt.Errorf("review: pending_fix_ttl %q is not a duration (e.g. 2h); unset means the default %s", r.PendingFixTTL, DefaultPendingFixTTL)
}
return nil
}

// DefaultReviewBotAuthors is review.bot_authors unset: the dependency and
// automation bots, plus any other `[bot]` login that is not the hive's own.
var DefaultReviewBotAuthors = []string{"dependabot[bot]", "renovate[bot]", "github-actions[bot]", "*[bot]"}
Expand Down
40 changes: 40 additions & 0 deletions src/pkg/config/review_dispatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,46 @@ func TestPendingReviewTTL(t *testing.T) {
}
}

// review.pending_fix_ttl reaches the planner's PendingFixTTL; before
// hivecommons/hive#14643 the 2h default could only be changed in code.
func TestPendingReviewFixTTL(t *testing.T) {
cases := []struct {
raw string
want time.Duration
}{
{"", DefaultPendingFixTTL},
{"0", DefaultPendingFixTTL},
{"garbage", DefaultPendingFixTTL},
{"30m", 30 * time.Minute},
{" 6h ", 6 * time.Hour},
{"-1s", -time.Second},
}
for _, tc := range cases {
if got := (ReviewConfig{PendingFixTTL: tc.raw}).PendingReviewFixTTL(); got != tc.want {
t.Fatalf("PendingReviewFixTTL(%q) = %v, want %v", tc.raw, got, tc.want)
}
}
if DefaultPendingFixTTL != 2*time.Hour {
t.Fatalf("DefaultPendingFixTTL = %v, want 2h (review.DefaultPendingFixTTL)", DefaultPendingFixTTL)
}
err := (ReviewConfig{PendingFixTTL: "soon"}).ValidatePendingFixTTL()
if err == nil || !strings.Contains(err.Error(), "pending_fix_ttl") {
t.Fatalf("ValidatePendingFixTTL(soon) = %v, want an error naming pending_fix_ttl", err)
}
for _, ok := range []string{"", "2h", "-1s"} {
if err := (ReviewConfig{PendingFixTTL: ok}).ValidatePendingFixTTL(); err != nil {
t.Fatalf("ValidatePendingFixTTL(%q) rejected: %v", ok, err)
}
}
// Config.Validate rejects it too, so a typo fails at load instead of
// silently running on the default.
cfg := validatableConfig(nil)
cfg.Review.PendingFixTTL = "soon"
if err := cfg.ValidateWithOptions(ValidateOptions{}); err == nil || !strings.Contains(err.Error(), "pending_fix_ttl") {
t.Fatalf("Config.Validate() = %v, want a pending_fix_ttl error", err)
}
}

func TestEffectiveSelfAuthoredDecisionPolicy(t *testing.T) {
if got := (ReviewConfig{}).EffectiveSelfAuthoredDecisionPolicy(); got != ReviewSelfAuthoredDecisionResolve {
t.Fatalf("unset policy = %q, want resolve", got)
Expand Down
3 changes: 3 additions & 0 deletions src/pkg/config/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ func (c *Config) ValidateWithOptions(opts ValidateOptions) error {
if err := c.Review.ValidateDeltaMaxAge(); err != nil {
return err
}
if err := c.Review.ValidatePendingFixTTL(); err != nil {
return err
}
if err := c.validateReviewPerspectiveModels(); err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions src/pkg/dashboard/settings_parity_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ review.bot_authors[] # TODO #14625
review.delta_max_age # TODO #14621
review.delta_rereview # TODO #14621
review.delta_trivial_lines # TODO #14621
review.pending_fix_ttl # TODO #14643
review.perspective_models.<key>.backend # TODO #13243
review.perspective_models.<key>.model # TODO #13243
review.perspective_prompts.<key> # TODO #11854
Expand Down
3 changes: 2 additions & 1 deletion src/pkg/review/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ type DispatchOptions struct {
// DefaultMaxRedispatch.
MaxRedispatch int
// PendingFixTTL is how long a pending fix row stays authoritative with
// no new head before the next bounded attempt replaces it. Zero means
// no new head before the next bounded attempt replaces it
// (review.pending_fix_ttl). Zero means
// DefaultPendingFixTTL; negative disables expiry. Attempts are capped by
// escalation.MaxReEngagements.
PendingFixTTL time.Duration
Expand Down
Loading