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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Contributor-lane auto-promotion now counts an author's clean merged PRs across every repository the hive manages (`auto_merge.contributor_lane.auto_promotion_scope: hive`, the default; `repo` restores the per-repository count), so a contributor trusted in the main repo is admitted on their first PR to a satellite repo; the audit marker and admission log carry the scope and a per-repo breakdown (#14517).
1 change: 1 addition & 0 deletions src/cmd/hive/merge_eligibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func contributorLanePolicyFunc(cfg *config.Config) func() automerge.ContributorL
RequireTiers: p.RequireTierSet(),
RegistryTiersSufficient: p.EffectiveRegistryTiersSufficient(),
AutoPromoteAfterMergedPR: tier.EffectiveAutoPromoteAfterMerged(),
AutoPromotionScope: p.EffectiveAutoPromotionScope(),
}
}
}
Expand Down
28 changes: 27 additions & 1 deletion src/docs/hive-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,28 @@ A PR merges through this tier only when all of the following hold:
with `contributor-lane:no-linked-issue`. The marker's `tier=` must be in
`require_tiers` (`contributor-lane:claim-tier-untrusted`) and it must say
`verified=true` (`contributor-lane:claim-unverified`).
- **Auto-promotion**: when the marker path fails on tier, the conservative
clean-history ratchet (`auto_merge.contributor_tier.auto_promote_after_merged`,
default 5; negative disables) admits the author if their last N merged
PRs have no revert or sentinel-alert evidence — none is itself a revert,
none carries the sentinel label, none was undone by a later merged
`Revert "<title>"` / "This reverts commit <sha>" PR — and the author is
not `revoked` in the registry. By default the merges are counted across
**every repository the hive manages**
(`auto_merge.contributor_lane.auto_promotion_scope: hive`): trust is a
property of the person, and the small satellite repos of a multi-repo
hive never reach the threshold on their own (hivecommons/docs#481 sat 17h
at `contributor-lane:claim-tier-untrusted` while the same author had nine
clean merges in hivecommons/hive; #14517). The PR's own repository is
walked first; only when it is short does one `search/issues` query
(`is:pr is:merged author:<login> repo:… repo:…`) find which other hive
repos hold the author's merges, and only those are walked for revert
evidence — a revert or sentinel hit in any repository blocks. The sweep
posts a `<!-- hive:contributor-auto-promoted author=… merged=N scope=hive
repos=hive:4,docs:1 -->` audit comment once per PR and logs
`contributor-lane admitted reason=contributor-lane:auto-promoted
merged_prs=5 scope=hive repos=hive:4,docs:1`. `auto_promotion_scope:
repo` restores the per-repository count.
- When neither admission path above vouches for the author, GitHub's
`author_association` for the PR author must be `OWNER`, `MEMBER`,
`COLLABORATOR` or `CONTRIBUTOR`; `NONE`, `FIRST_TIMER`,
Expand Down Expand Up @@ -491,11 +513,15 @@ auto_merge:
- trusted
- merger
registry_tiers_sufficient: true # a require_tiers tier on the author's registry profile admits without a claim marker
auto_promotion_scope: hive # count clean merged PRs across every hive repo (repo = this repository only)
contributor_tier:
auto_promote_after_merged: 5 # clean merged PRs before the lane trusts an author on its own; negative disables
```

The block is editable from **Settings → Features → Auto Merge →
Contributor-lane auto-merge** (enable switch, soak minutes, reviewer-verdict
switch, required tiers, excluded labels, repository allow-list) through the
switch, required tiers, auto-promotion scope, excluded labels, repository
allow-list) through the
same owner-only `GET/PUT /api/config/auto-merge` overlay.

**Operator workflow.** To let a known contributor's relay PRs merge
Expand Down
2 changes: 2 additions & 0 deletions src/docs/operator-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ advanced into the merge path.
| `auto_merge.contributor_lane.require_reviewer_verdict` | `true` | Require an approving aggregate reviewer verdict for the current head. Independently of this key, a hive with no reviewer agent never merges through the tier (`contributor-lane:no-reviewer`). |
| `auto_merge.contributor_lane.require_tiers` | `trusted`, `merger` | Contributor trust tiers whose verified claims the tier may merge. Only operator-granted tiers (`trusted`, `merger`, `advisor`) are accepted; `newcomer` and `contributor` are rejected at validation. |
| `auto_merge.contributor_lane.registry_tiers_sufficient` | `true` | Admit a PR whose author's contributor-registry profile carries a `require_tiers` tier without a linked issue or `hive:claim` marker (logged as `contributor-lane:registry-trusted`). All other gates still apply. `false` requires the claim marker for every contributor. |
| `auto_merge.contributor_lane.auto_promotion_scope` | `hive` | Where the clean-merged-PR ratchet (`auto_merge.contributor_tier.auto_promote_after_merged`) counts an author's merges: `hive` counts across every repository the hive manages (one `search/issues` query finds the repos holding the author's merges; the PR's own repo is always walked first), `repo` counts only the PR's repository. Revert and sentinel-alert evidence blocks promotion in either scope. |
| `auto_merge.contributor_tier.auto_promote_after_merged` | `5` | Clean merged PRs (no revert, no sentinel label, not undone by a later merged revert) after which the contributor lane treats an author as `trusted` without an operator grant, unless the registry marks them `revoked`. Negative disables the ratchet. |
| `auto_merge.contributor_lane.repos` | empty = all watched repos | Optional repo allow-list for the contributor-lane tier (bare name or `owner/repo`). |
| `auto_merge.contributor_lane.exclude_labels` | `hold`, `do-not-merge`, `needs-human`, `blocked`, `needs-rebase` | Labels that keep a PR out of contributor-lane auto-merge (`do-not-merge/*` always excluded). |

Expand Down
20 changes: 20 additions & 0 deletions src/pkg/config/automerge_trusted_bot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,26 @@ func TestContributorLaneAutoMergeConfigRequireTiers(t *testing.T) {
}
}

// auto_promotion_scope defaults to hive (fleet-wide clean-merge count,
// #14517), accepts repo, and rejects anything else.
func TestContributorLaneAutoMergeConfigAutoPromotionScope(t *testing.T) {
var cfg ContributorLaneAutoMergeConfig
if got := cfg.EffectiveAutoPromotionScope(); got != ContributorLaneAutoPromotionScopeHive {
t.Fatalf("default auto_promotion_scope = %q, want hive", got)
}
cfg.AutoPromotionScope = " Repo "
if err := cfg.Validate(); err != nil {
t.Fatalf("repo scope should validate: %v", err)
}
if got := cfg.EffectiveAutoPromotionScope(); got != ContributorLaneAutoPromotionScopeRepo {
t.Fatalf("auto_promotion_scope = %q, want repo (trimmed, lower-cased)", got)
}
cfg.AutoPromotionScope = "fleet"
if err := cfg.Validate(); err == nil || !strings.Contains(err.Error(), "auto_promotion_scope") {
t.Fatalf("invalid scope must fail validation, got %v", err)
}
}

func TestBotTakeoverAutoMergeConfigDefaultsOnAndHonorsExplicitOff(t *testing.T) {
var a AutoMergeConfig
if !a.BotTakeover.IsEnabled() {
Expand Down
33 changes: 33 additions & 0 deletions src/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7726,6 +7726,36 @@ type ContributorLaneAutoMergeConfig struct {
// than closes its issue, or was claimed outside the relay, waits for a
// human (`contributor-lane:no-linked-issue` / `no-claim`).
RegistryTiersSufficient *bool `yaml:"registry_tiers_sufficient,omitempty" json:"registry_tiers_sufficient,omitempty"`
// AutoPromotionScope is where the clean-merged-PR ratchet
// (auto_merge.contributor_tier.auto_promote_after_merged) counts an
// author's merges. `hive` (default) counts clean merged PRs across every
// repository this hive manages: trust in a contributor is a property of
// the person, and the small satellite repos of a multi-repo hive never
// reach a per-repo threshold on their own. `repo` counts only the PR's
// own repository (the pre-#14517 behaviour). Revert and sentinel-alert
// evidence is applied per PR in either scope.
AutoPromotionScope string `yaml:"auto_promotion_scope,omitempty" json:"auto_promotion_scope,omitempty"`
}

// Contributor-lane auto-promotion scopes
// (auto_merge.contributor_lane.auto_promotion_scope).
const (
ContributorLaneAutoPromotionScopeHive = "hive"
ContributorLaneAutoPromotionScopeRepo = "repo"
)

// ContributorLaneAutoPromotionScopes lists the accepted
// auto_promotion_scope values.
var ContributorLaneAutoPromotionScopes = []string{ContributorLaneAutoPromotionScopeHive, ContributorLaneAutoPromotionScopeRepo}

// EffectiveAutoPromotionScope returns the normalized auto_promotion_scope,
// defaulting to ContributorLaneAutoPromotionScopeHive.
func (c ContributorLaneAutoMergeConfig) EffectiveAutoPromotionScope() string {
scope := strings.ToLower(strings.TrimSpace(c.AutoPromotionScope))
if scope == "" {
return ContributorLaneAutoPromotionScopeHive
}
return scope
}

// ContributorTierAutoMergeConfig is auto_merge.contributor_tier.*.
Expand Down Expand Up @@ -7864,6 +7894,9 @@ func (c ContributorLaneAutoMergeConfig) Validate() error {
return fmt.Errorf("auto_merge.contributor_lane.require_tiers: %q is not an operator-granted tier (allowed: %s)", tier, strings.Join(ContributorLaneGrantableTiers, ", "))
}
}
if scope := c.EffectiveAutoPromotionScope(); scope != ContributorLaneAutoPromotionScopeHive && scope != ContributorLaneAutoPromotionScopeRepo {
return fmt.Errorf("auto_merge.contributor_lane.auto_promotion_scope: %q is not valid (allowed: %s)", c.AutoPromotionScope, strings.Join(ContributorLaneAutoPromotionScopes, ", "))
}
return nil
}

Expand Down
15 changes: 15 additions & 0 deletions src/pkg/dashboard/api_config_automerge.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func (s *Server) handleAutoMergePut(w http.ResponseWriter, r *http.Request) {
ExcludeLabels []string `json:"exclude_labels"`
RequireTiers []string `json:"require_tiers"`
RegistryTiersSufficient *bool `json:"registry_tiers_sufficient"`
AutoPromotionScope *string `json:"auto_promotion_scope"`
} `json:"contributor_lane"`
}
if err := decodeBody(r, &body); err != nil {
Expand Down Expand Up @@ -215,6 +216,7 @@ func (s *Server) handleAutoMergePut(w http.ResponseWriter, r *http.Request) {
var contributorLaneRepos []string
var contributorLaneLabels []string
var contributorLaneTiers []string
var contributorLaneScope string
if body.ContributorLane != nil {
if body.ContributorLane.SoakMinutes != nil && *body.ContributorLane.SoakMinutes < 0 {
jsonError(w, "contributor_lane.soak_minutes must be 0 (default 30) or greater", http.StatusBadRequest)
Expand All @@ -241,6 +243,14 @@ func (s *Server) handleAutoMergePut(w http.ResponseWriter, r *http.Request) {
}
contributorLaneTiers = normalizeAutoMergeRepoList(body.ContributorLane.RequireTiers)
}
if body.ContributorLane.AutoPromotionScope != nil {
scope := config.ContributorLaneAutoMergeConfig{AutoPromotionScope: *body.ContributorLane.AutoPromotionScope}
if err := scope.Validate(); err != nil {
jsonError(w, "contributor_lane.auto_promotion_scope must be one of "+strings.Join(config.ContributorLaneAutoPromotionScopes, ", "), http.StatusBadRequest)
return
}
contributorLaneScope = scope.EffectiveAutoPromotionScope()
}
}

// --- apply ---
Expand Down Expand Up @@ -321,6 +331,9 @@ func (s *Server) handleAutoMergePut(w http.ResponseWriter, r *http.Request) {
if body.ContributorLane.RequireTiers != nil {
cfg.AutoMerge.ContributorLane.RequireTiers = contributorLaneTiers
}
if body.ContributorLane.AutoPromotionScope != nil {
cfg.AutoMerge.ContributorLane.AutoPromotionScope = contributorLaneScope
}
}
syncAutoMergePolicyToGitHubClient(cfg, s.deps.GHClient)

Expand Down Expand Up @@ -404,6 +417,8 @@ func autoMergeSectionResponse(cfg *config.Config) map[string]interface{} {
"exclude_labels": contributorLaneLabels,
"require_tiers": cl.EffectiveRequireTiers(),
"registry_tiers_sufficient": cl.EffectiveRegistryTiersSufficient(),
"auto_promotion_scope": cl.EffectiveAutoPromotionScope(),
"auto_promotion_scopes": config.ContributorLaneAutoPromotionScopes,
"grantable_tiers": config.ContributorLaneGrantableTiers,
},
}
Expand Down
12 changes: 12 additions & 0 deletions src/pkg/dashboard/api_config_sections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,8 @@ func TestAutoMergeGet_ContributorLaneDefaults(t *testing.T) {
ExcludeLabels []string `json:"exclude_labels"`
RequireTiers []string `json:"require_tiers"`
RegistryTiers bool `json:"registry_tiers_sufficient"`
AutoPromotionScope string `json:"auto_promotion_scope"`
AutoPromotionScopes []string `json:"auto_promotion_scopes"`
GrantableTiers []string `json:"grantable_tiers"`
} `json:"contributor_lane"`
}
Expand All @@ -655,6 +657,9 @@ func TestAutoMergeGet_ContributorLaneDefaults(t *testing.T) {
if !cl.Enabled || cl.SoakMinutes != config.DefaultContributorLaneSoakMinutes || !cl.RequireReviewerVerdict || !cl.RegistryTiers || len(cl.Repos) != 0 {
t.Fatalf("contributor_lane defaults wrong: %+v", cl)
}
if cl.AutoPromotionScope != config.ContributorLaneAutoPromotionScopeHive || strings.Join(cl.AutoPromotionScopes, ",") != "hive,repo" {
t.Fatalf("contributor_lane auto_promotion_scope defaults wrong: %+v", cl)
}
if strings.Join(cl.ExcludeLabels, ",") != strings.Join(config.DefaultContributorLaneExcludeLabels, ",") {
t.Fatalf("contributor_lane default labels wrong: %v", cl.ExcludeLabels)
}
Expand All @@ -671,6 +676,7 @@ func TestAutoMergePut_ContributorLaneValidation(t *testing.T) {
"repos": []string{" widget ", ""},
"exclude_labels": []string{"hold"},
"require_tiers": []string{" merger "},
"auto_promotion_scope": " Repo ",
},
}
if rec := doPut(s, "/api/config/auto-merge", valid); rec.Code != http.StatusOK {
Expand All @@ -680,6 +686,12 @@ func TestAutoMergePut_ContributorLaneValidation(t *testing.T) {
if cl.IsEnabled() || cl.EffectiveSoakMinutes() != 30 || cl.EffectiveRequireReviewerVerdict() || cl.EffectiveRegistryTiersSufficient() {
t.Fatalf("contributor_lane write did not apply: %+v", cl)
}
if cl.AutoPromotionScope != config.ContributorLaneAutoPromotionScopeRepo {
t.Fatalf("contributor_lane auto_promotion_scope not normalized: %q", cl.AutoPromotionScope)
}
if rec := doPut(s, "/api/config/auto-merge", map[string]any{"contributor_lane": map[string]any{"auto_promotion_scope": "fleet"}}); rec.Code != http.StatusBadRequest {
t.Fatalf("invalid auto_promotion_scope: expected 400, got %d", rec.Code)
}
if strings.Join(cl.Repos, ",") != "widget" || strings.Join(cl.ExcludeLabels, ",") != "hold" {
t.Fatalf("contributor_lane lists not normalized: repos=%v labels=%v", cl.Repos, cl.ExcludeLabels)
}
Expand Down
1 change: 0 additions & 1 deletion src/pkg/dashboard/settings_parity_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ agents.<key>.variables.<key>.url # TODO #11854
agents.<key>.variables.<key>.value # TODO #11854
agents.github_api_hourly_cap # TODO #11854
auto_merge.allow_unprotected_base[] # TODO #11854
auto_merge.contributor_tier.auto_promote_after_merged # contributor trust ratchet; yaml-only (#12839)
auto_merge.human_merge_paths.<key> # TODO #11854
auto_merge.merge_forward_trusted_human[] # TODO #11854
auto_merge.no_ci_ok[] # TODO #11854
Expand Down
Loading
Loading