diff --git a/changelog.d/added-review-pending-fix-ttl.md b/changelog.d/added-review-pending-fix-ttl.md new file mode 100644 index 0000000000..2effcfbe91 --- /dev/null +++ b/changelog.d/added-review-pending-fix-ttl.md @@ -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). diff --git a/src/cmd/hive/main.go b/src/cmd/hive/main.go index 31cbbe4abb..446dcc78e3 100644 --- a/src/cmd/hive/main.go +++ b/src/cmd/hive/main.go @@ -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, diff --git a/src/docs/labels-and-control-signals.md b/src/docs/labels-and-control-signals.md index 500a1f1629..7016410337 100644 --- a/src/docs/labels-and-control-signals.md +++ b/src/docs/labels-and-control-signals.md @@ -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, diff --git a/src/docs/review-swarm.md b/src/docs/review-swarm.md index 9264bc1354..c2501d62a1 100644 --- a/src/docs/review-swarm.md +++ b/src/docs/review-swarm.md @@ -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 diff --git a/src/hive.yaml.example b/src/hive.yaml.example index 5a675cf660..072134ce91 100644 --- a/src/hive.yaml.example +++ b/src/hive.yaml.example @@ -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 diff --git a/src/pkg/config/config.go b/src/pkg/config/config.go index a6af0979d7..29fe476c9f 100644 --- a/src/pkg/config/config.go +++ b/src/pkg/config/config.go @@ -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 diff --git a/src/pkg/config/review_dispatch.go b/src/pkg/config/review_dispatch.go index 2e256df99f..f793e81967 100644 --- a/src/pkg/config/review_dispatch.go +++ b/src/pkg/config/review_dispatch.go @@ -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" @@ -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 { @@ -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]"} diff --git a/src/pkg/config/review_dispatch_test.go b/src/pkg/config/review_dispatch_test.go index 146f570284..a1e9f0e841 100644 --- a/src/pkg/config/review_dispatch_test.go +++ b/src/pkg/config/review_dispatch_test.go @@ -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) diff --git a/src/pkg/config/validate.go b/src/pkg/config/validate.go index 8990fdb178..229ad8348c 100644 --- a/src/pkg/config/validate.go +++ b/src/pkg/config/validate.go @@ -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 } diff --git a/src/pkg/dashboard/settings_parity_allowlist.txt b/src/pkg/dashboard/settings_parity_allowlist.txt index 803a3107e7..7d21c3c739 100644 --- a/src/pkg/dashboard/settings_parity_allowlist.txt +++ b/src/pkg/dashboard/settings_parity_allowlist.txt @@ -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..backend # TODO #13243 review.perspective_models..model # TODO #13243 review.perspective_prompts. # TODO #11854 diff --git a/src/pkg/review/dispatch.go b/src/pkg/review/dispatch.go index d817fbf77e..dfa964fc12 100644 --- a/src/pkg/review/dispatch.go +++ b/src/pkg/review/dispatch.go @@ -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