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 @@
- Merge lanes: pull requests on a repo an owner switched off with `auto_merge: false` at L6 now get a stage record every pass (090 "auto-merge off" once approved and green) from an observe-only pass that never merges, enqueues, updates a branch, rebases or otherwise writes to GitHub; hives below L6 are unchanged.
1 change: 1 addition & 0 deletions src/cmd/hive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2371,6 +2371,7 @@ func (b *boot) bootAgentsWith(deps bootAgentsDeps) {
autoMergeOpts.SelfAuthorizationHoldEnabled = selfAuthorizationHoldEnabled
autoMergeOpts.MinHeadAge = b.cfg.AutoMerge.EffectiveMinHeadAge()
autoMergeOpts.RepoAutoMergeEnabled = func(repo string) bool { return b.cfg.RepoAutoMergeEnabled(repo) }
autoMergeOpts.RepoAutoMergeSwitchedOff = func(repo string) bool { return b.cfg.RepoAutoMergeSwitchedOff(repo) }
autoMergeOpts.RepoOnGitHub = func(repo string) bool { return b.cfg.RepoOnGitHub(repo) }
// Read through b.cfg on every sweep tick so a config reload of
// auto_merge.trusted_bot_authors takes effect without a restart.
Expand Down
1 change: 1 addition & 0 deletions src/cmd/hive/main_sweeps.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ func runAutoMergeSweepIfDue(ctx context.Context, ghClient *github.Client, cfg *c
opts.RequiredChecksForRepo = cfg.AutoMerge.RequiredCheckSetForRepo
opts.MinHeadAge = cfg.AutoMerge.EffectiveMinHeadAge()
opts.RepoAutoMergeEnabled = func(repo string) bool { return cfg.RepoAutoMergeEnabled(repo) }
opts.RepoAutoMergeSwitchedOff = func(repo string) bool { return cfg.RepoAutoMergeSwitchedOff(repo) }
opts.QueueOnApproveAndUnhold = func(repo string) bool {
return cfg.AutoMerge.QueueOnApproveAndUnholdAllowed(repo, cfg.ACMMLevel)
}
Expand Down
4 changes: 3 additions & 1 deletion src/docs/hive-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ here. A repo with that switch off may still receive Hive-opened PRs, but the
relay refuses to merge them and reports that auto-merge is disabled for the
repository. The same repo policy is enforced by the App self-merge sweep and by
the proxy's direct REST/GraphQL merge denial path, so agents cannot bypass it
by calling GitHub directly.
by calling GitHub directly. The merge lanes still evaluate such a repo's PRs
in an observe-only mode that records a stage (090 *auto-merge off*) and writes
nothing else.

On top of `AuthorizeMerge`, the watcher's authorizer is wrapped with a second,
target-specific check (the F4 target-binding, CWE-863) before any merge is
Expand Down
4 changes: 2 additions & 2 deletions src/docs/labels-and-control-signals/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Some hive-authored labels look like provenance but are read as signals, so they
| `hold` from #5117 self-authorization | PRs | PR-request watcher and self-authorization release | A PR whose only rationale is unacknowledged hive-filed issues gets literal `hold`. Acknowledging the issue later does not remove an existing PR hold by itself. At ACMM L6 (Autonomous), the unset default is off; lower levels default on. | Hard merge gate | Hive App | PR creation; evaluated only when no level hold applies | Acknowledge the issue and remove the PR `hold`; disabled policy release can remove Hive's own hold. At L6, that release path also clears existing Hive-applied #5117 holds when no explicit config keeps the policy on. | `github.self_authorization_hold`, per-repo `project.repo_policies[].self_authorization_hold`, `HIVE_SELF_AUTHORIZATION_HOLD` (`src/pkg/github/pr_self_authorization.go:14-226`, `src/pkg/github/pr_request_watcher.go:452-524`) |
| `triage/accepted` (or `project.issue_filter.reporter_trust.untrusted_require_labels`); `needs-triage` while waiting | Human-filed issues from untrusted reporters | GitHub enumeration | With `reporter_trust.enabled: true`, an issue whose reporter's GitHub `author_association` is outside the trusted set (default `OWNER`, `MEMBER`, `COLLABORATOR`) and whose login is not in `trusted_logins` is not actionable until it carries one of these labels. On the first excluded scan, core `github.Client.fetchIssues` posts one marked explanation comment and applies `needs-triage` (or `awaiting_label`); later scans do not repeat the comment. This is a poller-side write, not an agent prompt, and is capped at 10 new notices per poll. When the triage label appears, the same poll loop removes `needs-triage` only if the marker records that Hive added it, then the issue enters the backlog. Independently of the marker, the stage sweep removes `needs-triage` once the issue reaches 020 or later (claiming settles triage; see `stage/015-triage-needed` below) β€” this is what retires the `needs-triage` that `fleetreport` stamps on hive-filed self-reports at filing. Trusted reporters' issues pass untouched. Runs after holds/exempts and before `require_labels`, so the ordinary allow-list still applies afterwards. Hive- and bot-filed issues are not judged here (#5117 owns them). Counted as "needs triage" on the repo card, not as a generic filter refusal. | Hard admission gate (off by default) | Human; Hive App for the visibility comment/label | Enumeration | Add the label, trust the login or association under **Settings β†’ Labels β†’ Reporter trust**, or disable the gate | `project.issue_filter.reporter_trust.{enabled,trusted_associations,trusted_logins,untrusted_require_labels,awaiting_label,comment}` (`src/pkg/config/reporter_trust.go`, `src/pkg/github/client.go` `fetchIssues`) |
| `hold` from #9665 reporter trust | PRs **not authored by the hive** | PR-request watcher, level-hold release | A PR whose rationale traces to an issue filed by an untrusted reporter gets literal `hold` at **every** ACMM level, including L6, plus `needs-human` (so it surfaces as waiting on a person, #10773) and a marked notice (`<!-- hive:reporter-trust-hold:9665 -->` + `<!-- hive:reporter-trust-metadata {…} -->`) naming the untrusted reporter and stating that the hold concerns the issue reporter, not the PR author. The rationale is **only the linked issues**: closing-keyword links (`Fixes`/`Closes`/`Resolves`) and the request's declared issues β€” bare `#N` mentions are not consulted, and a link that resolves to a pull request is skipped rather than judged (hivecommons/hive#15020: `Refs #15009 (closed by #15017)` made the gate judge sibling PR #15017 and attribute a `CONTRIBUTOR` who had merely commented). A hive-filed issue (`[selfreport]`, app or AI author) counts as trusted. The gate is **skipped entirely for hive-authored PRs** (App bot, `project.ai_author`, `author/hive`): the hive is the author, so the reporter's trust says nothing about whether its own fix may merge; it still applies to contributor PRs and to PRs opened under a shared PAT account. Any one untrusted citation holds. Evaluated even at hold-gated levels, because the notice is what stops promotion to L6 from releasing the label. | Hard merge gate | Hive App | PR creation; re-checked by the level-hold release path | A human removes `hold` on a contributor PR; Hive never auto-releases it there. On a **hive-authored** PR still wearing a hive-set reporter-trust hold (newest `hold` event labeled by the App bot with the notice at or after it β€” a person's hold is left alone), the stage-label pass releases `hold` (and `needs-human` when the notice says the gate added it), posts one `<!-- hive:reporter-trust-release -->` comment and logs `stage labels: releasing self-imposed reporter-trust hold`. The pass also records the hold's provenance (`by`, `source`, `reason`, `since`) on the stage store, so the tracker pill reads *Held by hive Β· reporter trust (issue #N by @X, contributor)* and the 085 comment names who set the hold and why. Holdguard re-holds on a new head SHA. | `github.reporter_trust_hold` (nil follows `reporter_trust.enabled`), per-repo `project.repo_policies[].reporter_trust_hold`, `HIVE_REPORTER_TRUST_HOLD` (`src/pkg/github/pr_reporter_trust.go`, `src/pkg/github/pr_level_hold.go`, `src/pkg/github/automerge/reporter_trust_release.go`) |
| `project.repo_policies[].auto_merge: false` | PRs | `hive-merge` relay, App self-authored auto-merge sweep, proxy | Below L6 this resolves off for every repo; at L6, PRs can still be opened, reviewed and held when the per-repo switch is off, but Hive refuses every merge path for that repo. Existing `hold` / `hive-pause/<hive-id>` labels stay put because the disabled repo is skipped before hold release or merge. | Hard merge gate | Operator/dashboard | Merge relay request, self-merge sweep tick, proxy direct merge attempt | Dashboard repo-card switch or config edit sets `auto_merge: true`/removes the override at L6; enabling is rejected below L6 | `project.repo_policies[].auto_merge` (`src/pkg/config/repo_policy.go`, `src/crux/agent/manager_modes.go`, `src/pkg/github/automerge/automerge_sweep.go`, `src/pkg/proxy/rules.go`) |
| `project.repo_policies[].auto_merge: false` | PRs | `hive-merge` relay, App self-authored auto-merge sweep, proxy | Below L6 this resolves off for every repo; at L6, PRs can still be opened, reviewed and held when the per-repo switch is off, but Hive refuses every merge path for that repo. At L6 the merge lanes still evaluate a switched-off repo's PRs each pass in an observe-only mode that records a stage (090 *auto-merge off* once approved and green) and writes nothing else, so existing `hold` / `hive-pause/<hive-id>` labels stay put; below L6 the lanes skip the repo and stage nothing. | Hard merge gate | Operator/dashboard | Merge relay request, self-merge sweep tick, proxy direct merge attempt | Dashboard repo-card switch or config edit sets `auto_merge: true`/removes the override at L6; enabling is rejected below L6 | `project.repo_policies[].auto_merge` (`src/pkg/config/repo_policy.go`, `src/crux/agent/manager_modes.go`, `src/pkg/github/automerge/automerge_sweep.go`, `src/pkg/proxy/rules.go`) |
| `hold` from holdguard | PRs | Holdguard ledger | If the head SHA changes while held, lifting the hold causes Hive to comment and re-apply literal `hold`; the next human removal is the fresh approval. Exception (#13603): when a human (not a Hive account, not a bot) removed the gate label after the current head arrived on the branch, they reviewed the current head, so the lift clears without a comment or re-hold. The head is accepted only on evidence a contributor cannot forge: the server-stamped `head_ref_force_pushed` timeline event that produced it (dated before the lift), or the hive itself having observed that exact head on the PR while the gate was still on (`observed_held_head_sha` in the holdguard ledger). Commit committer dates and SHA-keyed `check_suite` / `status` times are never used; a push after the lift, or a head the hive never saw while held, still re-holds. | Hard merge gate | Hive | Governor holdguard pass | Human removes the re-applied hold | Built-in `holdguard.ReHoldLabel` (`src/pkg/holdguard/holdguard.go:1-43`) |
| `hold` from SHA-hold | Issues | SHA-hold sweep | Human-filed primary-repo `kind/bug` without a 7-40 hex SHA gets `hold` and a notice carrying `<!-- hive:sha-hold -->`; once a SHA appears in body/comments, Hive removes `hold` only if the current hold is its own (newest `hold` event labeled by the App bot, paired with an App-authored notice at or after it). A human's hold, a re-hold, or another subsystem's hold stays. Reporters whose author association is trusted (`issue_filter.reporter_trust.trusted_associations`, default OWNER/MEMBER/COLLABORATOR) get the soft `needs-sha` row below instead, and a SHA-hold `hold` already on such an issue is swapped for it (#12002). The hard-suppress reconcile also lifts this `hold` once a PR referencing the issue merges after it was applied. | Hard issue hold | Hive | Eval tick SHA sweep; hard-suppress reconcile | Add SHA evidence or merge the fix; sweep removes its own `hold`, a human removes any other | Primary repo and SHA-hold config (`src/pkg/github/client.go` `EnforceSHAHold`, `src/pkg/github/hard_suppress_reconcile.go`) |
| `needs-sha` from SHA-hold | Issues | SHA-hold sweep | Trusted-reporter `kind/bug` without a SHA gets this soft label plus the same `<!-- hive:sha-hold -->` notice instead of `hold`; the issue stays actionable. The sweep removes it once a SHA appears. | Soft (informational) | Hive | Eval tick SHA sweep | Add SHA evidence, or remove the label | `issues.sha_hold_trusted_label` (default `needs-sha`; `hold` restores the hard hold for everyone) |
Expand Down Expand Up @@ -807,7 +807,7 @@ On by default (`good_first_issue.enabled: false` opts out), hive applies both la

**Applies to:** PRs. **Kind:** Hard merge gate.

Below L6 this resolves off for every repo; at L6, PRs can still be opened, reviewed and held when the per-repo switch is off, but Hive refuses every merge path for that repo. Existing `hold` / `hive-pause/<hive-id>` labels stay put because the disabled repo is skipped before hold release or merge.
Below L6 this resolves off for every repo; at L6, PRs can still be opened, reviewed and held when the per-repo switch is off, but Hive refuses every merge path for that repo. At L6 the merge lanes still evaluate a switched-off repo's PRs each pass in an observe-only mode that records a stage (090 *auto-merge off* once approved and green) and writes nothing else, so existing `hold` / `hive-pause/<hive-id>` labels stay put; below L6 the lanes skip the repo and stage nothing.

**Who applies it:** Operator/dashboard.

Expand Down
27 changes: 27 additions & 0 deletions src/pkg/config/config_extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,33 @@ func TestRepoAutoMergeEnabledFailsClosedBelowL6(t *testing.T) {
}
}

func TestRepoAutoMergeSwitchedOffIsL6ExplicitOffOnly(t *testing.T) {
f := false
tr := true
level := SelfMergeMinACMMLevel
cfg := &Config{ACMMLevel: &level, Project: ProjectConfig{
Org: "acme",
RepoPolicies: []RepoPolicy{
{Repo: "api", AutoMerge: &f},
{Repo: "web", AutoMerge: &tr},
},
}}
if !cfg.RepoAutoMergeSwitchedOff("api") || !cfg.RepoAutoMergeSwitchedOff("ACME/API") {
t.Fatal("auto_merge=false at L6 is switched off")
}
if cfg.RepoAutoMergeSwitchedOff("acme/web") || cfg.RepoAutoMergeSwitchedOff("other") {
t.Fatal("auto_merge=true or no override is not switched off")
}
below := SelfMergeMinACMMLevel - 1
cfg.ACMMLevel = &below
if cfg.RepoAutoMergeEnabled("api") || cfg.RepoAutoMergeSwitchedOff("api") {
t.Fatal("below L6 auto-merge is off everywhere but no repo counts as switched off")
}
if (*Config)(nil).RepoAutoMergeSwitchedOff("acme/api") {
t.Fatal("nil config is not switched off")
}
}

func TestSetSelfAuthorizationHoldForRepos(t *testing.T) {
cfg := &Config{
SourcePath: writeTempConfig(t, "project:\n org: acme\n repos: [api]\ngithub:\n token: ghp_tok\nagents:\n bot:\n backend: claude\n"),
Expand Down
13 changes: 13 additions & 0 deletions src/pkg/config/repo_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,19 @@ func (c *Config) RepoAutoMergeEnabled(repo string) bool {
return true
}

// RepoAutoMergeSwitchedOff reports whether an owner switched this repo's
// auto-merge off with `project.repo_policies[].auto_merge: false` at L6 or
// above. It is the observe-only staging predicate (hivecommons/hive#17552):
// below L6 RepoAutoMergeEnabled is false for every repo, but those hives
// are not staged, so this is narrower than !RepoAutoMergeEnabled.
func (c *Config) RepoAutoMergeSwitchedOff(repo string) bool {
if c == nil || c.ACMMLevelOrZero() < SelfMergeMinACMMLevel {
return false
}
rp, ok := c.RepoPolicyFor(repo)
return ok && rp.AutoMerge != nil && !*rp.AutoMerge
}

// SetRepoAutoMergeForRepoAndSave records, clears, and persists one repo's
// auto-merge override. nil clears the override so the repo inherits default ON.
func (c *Config) SetRepoAutoMergeForRepoAndSave(repo string, enabled *bool) (bool, error) {
Expand Down
9 changes: 8 additions & 1 deletion src/pkg/github/automerge/automerge_contributor_lane.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,14 @@ func (c *Engine) SweepContributorLaneAutoMerges(ctx context.Context, opts AutoMe
continue
}
if !c.repoAutoMergeAllowed(displayRepo) {
c.info("contributor-lane automerge sweep skipped repo", "repo", displayRepo, "reason", "repo-auto-merge-disabled")
c.info("contributor-lane automerge sweep skipped repo", "repo", displayRepo, "reason", "repo-auto-merge-disabled", "observe_only", c.stagePolicy().Enabled && c.repoObservedOnly(displayRepo))
c.observeAutoMergeOffRepo(ctx, stageLaneContributor, displayRepo, opts.Targets, func(ctx context.Context, oc *Engine, owner, repoName string, pr *gh.PullRequest) (string, error) {
if reason := oc.sentinelBlockedUnlessHumanChangesRequested(ctx, owner, repoName, pr, oc.prefilterContributorLanePR(pr, policy)); reason != "" {
return reason, nil
}
_, reason, err := oc.trySweepContributorLanePR(mergeDecisionPriority(ctx), displayRepo, owner, repoName, pr.GetNumber(), policy)
return reason, err
})
continue
}
prs, skipReason, err := c.openPullRequests(ctx, owner, repoName, opts.Targets)
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/github/automerge/automerge_merge_train.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ func mergeTrainCandidate(prefilterReason string) bool {
// train, so a failed read never blocks a merge the lane would have made.
func (c *Engine) planMergeTrains(ctx context.Context, lane, displayRepo, owner, repo string, prs []*gh.PullRequest, prefilter func(*gh.PullRequest) string) *mergeTrainPlan {
plan := &mergeTrainPlan{lane: lane, displayRepo: displayRepo, owner: owner, repo: repo, byNumber: map[int]*mergeTrainGroup{}, candidates: map[int]*mergeTrainGroup{}}
if !c.mergeTrainPolicyNow().Enabled || c == nil || c.gh == nil {
if !c.mergeTrainPolicyNow().Enabled || c == nil || c.gh == nil || c.observeOnly {
return plan
}
defer c.mergeTrainSettleSeats(lane, owner, repo, displayRepo, prs, plan)
Expand Down
17 changes: 15 additions & 2 deletions src/pkg/github/automerge/automerge_native_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,30 @@ func (c *Engine) nativeQueue(repo string) nativeQueueTransport {
return c.nativeQueueTransport()
}

const (
integrationMemberCaptureUnavailable = "integration exact member capture unavailable"
integrationMemberIdentityChanged = "integration exact member identity changed"
)

// routeIntegrationMerge applies the exact-member capture and execution
// authority before either serialized or direct merge execution.
func (c *Engine) routeIntegrationMerge(ctx context.Context, pr *gh.PullRequest, claim effects.Claim) (bool, string, error) {
if capture, ok := ctx.Value(integrationEligibilityContextKey{}).(*integrationEligibilityCapture); ok {
if capture == nil {
return false, "integration exact member capture unavailable", nil
return false, integrationMemberCaptureUnavailable, nil
}
if pr.GetNumber() != capture.number || pr.GetHead().GetSHA() != capture.head || pr.GetBase().GetRef() != capture.base ||
pr.GetBase().GetRepo().GetFullName() != capture.repo {
return false, "integration exact member identity changed", nil
return false, integrationMemberIdentityChanged, nil
}
capture.pr = pr
return false, integrationEligibilityCaptured, nil
}
if c.observeOnly {
// An observe-only pass stops at the merge decision: no merge, no
// native-queue enqueue (automerge_observe_only.go).
return false, observeOnlyReasonRepoAutoMergeDisabled, nil
}
requiredNative := false
if c.integrationExecution != nil {
decision, err := c.integrationExecution(ctx, claim.Repo, pr, c.IntegrationEligibility)
Expand Down Expand Up @@ -361,6 +371,9 @@ func (c *Engine) tryNativeQueueAfterRouting(ctx context.Context, pr *gh.PullRequ
// reconcileNativeQueueGate runs for the owning lane's rejected candidates,
// including cheap prefilter holds. Never withdraw another actor's entry.
func (c *Engine) reconcileNativeQueueGate(ctx context.Context, lane, owner, repo string, pr *gh.PullRequest, reason string) {
if c == nil || c.observeOnly {
return
}
t := c.nativeQueue(owner + "/" + repo)
if t == nil || pr == nil || pr.GetNodeID() == "" || !nativeQueueWithdrawReason(reason) {
return
Expand Down
Loading
Loading