diff --git a/changelog.d/added-automerge-current-base-switch.md b/changelog.d/added-automerge-current-base-switch.md new file mode 100644 index 0000000000..9a8798ce3d --- /dev/null +++ b/changelog.d/added-automerge-current-base-switch.md @@ -0,0 +1 @@ +- Settings → Features → Auto-merge gains a "Merge only on current base" switch (`auto_merge.require_current_base_default`, **off** by default) and each row on the Repos tab a per-repo inherit / on / off override (`auto_merge.require_current_base` / `auto_merge.skip_current_base`); the repo card shows a `current-base` chip when the gate is on. A gated repo only merges a head that contains the current base tip — a green head whose base has moved is updated with GitHub update-branch and merges once CI is green on the new head, which would have stopped the stale-green merge that broke `v5` for every open PR for 20 minutes. Explicitly listed repos are strict; repos gated only by the default merge a head the App cannot update (fork without maintainer edits, branch protection) as tested, with one WARN per PR. The fleet default stays off while the gate soaks on hive's own hive ([#15335](https://github.com/hivecommons/hive/issues/15335)). diff --git a/changelog.d/changed-automerge-require-current-base-default.md b/changelog.d/changed-automerge-require-current-base-default.md deleted file mode 100644 index 0ff13a8c00..0000000000 --- a/changelog.d/changed-automerge-require-current-base-default.md +++ /dev/null @@ -1 +0,0 @@ -- **Breaking (merge behaviour):** the auto-merge current-base gate (`auto_merge.require_current_base`) is now on for every repository by default. A green head whose base has moved is brought up to date with GitHub update-branch and merges once CI is green on the new head; a stale-green merge (#15236) had broken `v5` for every open PR for 20 minutes. Opt a repo out with `auto_merge.skip_current_base: [owner/repo]`, or set `auto_merge.require_current_base_default: false` to return to opt-in only. Repos listed explicitly in `require_current_base` are strict; repos gated only by the default merge a head the App cannot update (fork without maintainer edits, branch protection) as tested, with one WARN per PR ([#15335](https://github.com/hivecommons/hive/issues/15335)). diff --git a/src/docs/api-reference/auth.md b/src/docs/api-reference/auth.md index 91913b0ffb..a3569a8c53 100644 --- a/src/docs/api-reference/auth.md +++ b/src/docs/api-reference/auth.md @@ -24,6 +24,6 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f | `GET` | `/api/openrouter/models` | Dashboard auth/session | Open Router Models | `pkg/dashboard/openrouter.go:47` | | `GET` | `/api/openrouter/credit` | Dashboard auth/session | Open Router Credit | `pkg/dashboard/openrouter.go:48` | | `GET` | `/openrouter/callback` | Public | Open Router Callback | `pkg/dashboard/openrouter.go:49` | -| `POST` | `/api/github-app/recheck` | Dashboard auth/session | GitHub App Recheck | `pkg/dashboard/server.go:1621` | -| `POST` | `/api/github-app/install-clicked` | Dashboard auth/session | GitHub App Install Clicked | `pkg/dashboard/server.go:1622` | -| `GET` | `/gh-setup` | Public | GitHub App Setup Callback | `pkg/dashboard/server.go:1623` | +| `POST` | `/api/github-app/recheck` | Dashboard auth/session | GitHub App Recheck | `pkg/dashboard/server.go:1626` | +| `POST` | `/api/github-app/install-clicked` | Dashboard auth/session | GitHub App Install Clicked | `pkg/dashboard/server.go:1627` | +| `GET` | `/gh-setup` | Public | GitHub App Setup Callback | `pkg/dashboard/server.go:1628` | diff --git a/src/docs/api-reference/dashboard-misc.md b/src/docs/api-reference/dashboard-misc.md index 4955e54ec8..75bd57e12b 100644 --- a/src/docs/api-reference/dashboard-misc.md +++ b/src/docs/api-reference/dashboard-misc.md @@ -63,4 +63,4 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f | `POST` | `/api/hives/{id}/heartbeat` | Dashboard auth/session | Hives Heartbeat | `pkg/dashboard/api_contribute.go:275` | | `DELETE` | `/api/hives/{id}` | Owner only | Hives Delete | `pkg/dashboard/api_contribute.go:276` | | `POST` | `/api/hives/onboard` | Dashboard auth/session | Hives Onboard | `pkg/dashboard/api_contribute.go:277` | -| `GET` | `/sso` | Public | SSO | `pkg/dashboard/server.go:1628` | +| `GET` | `/sso` | Public | SSO | `pkg/dashboard/server.go:1633` | diff --git a/src/docs/api-reference/health-status-events.md b/src/docs/api-reference/health-status-events.md index 00d2854b6b..434f07f22b 100644 --- a/src/docs/api-reference/health-status-events.md +++ b/src/docs/api-reference/health-status-events.md @@ -8,17 +8,17 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f | `GET` | `/api/version` | Dashboard auth/session | Build/version metadata; includes `upgradeMarker` (`target`, `current`, `attempts`, `maxAttempts`, `failed`, `requestedAt`, `lastError`) while a self-upgrade is in flight or has failed ([#6765](https://github.com/hivecommons/hive/issues/6765)), the hub-delivered `upgradePolicy` (`hub_managed`, `spoke_managed`, `schedule`, `schedule_hour`, `schedule_timezone`, `schedule_weekday`, `paused`, `branch`, `channel`, `target_sha`, `target_resolved`, `armed_target`, and `next_update_at` — the hub's RFC3339 ETA for the next promotion into the `stable` channel, omitted when unknown ([#10256](https://github.com/hivecommons/hive/issues/10256))) when available, and an `autoUpdate` object (`enabled`, `state` — one of `disabled`/`up_to_date`/`behind`/`retrying`/`failed`/`unknown` — `healthy`, `period`, `targetBranch`, `targetCommit`, `currentCommit`, `commitsBehind`, `lastAttemptAt`, `lastError`, `detail`, and `nextUpdateAt` — the hub's RFC3339 ETA for the next update, omitted when unknown, disabled or paused ([#10257](https://github.com/hivecommons/hive/issues/10257))) that never reports a failed or unknown update as healthy ([#6962](https://github.com/hivecommons/hive/issues/6962), [#6963](https://github.com/hivecommons/hive/issues/6963)) | `pkg/dashboard/api.go:43` | | `GET` | `/api/version/release-notes` | Dashboard auth/session | Changelog gap between two revisions: `?from=&to=` returns `{from:{sha,version?}, to:{sha,ref,version?}, sections:[{version,date,categories:{added,changed,fixed,security,deprecated}}], unreleased?, truncated, source, error?}` — the `CHANGELOG.md` release sections present at `to` and absent at `from`, newest first, plus (when `to` is not a release tag) the `changelog.d/` fragments new at `to` under an `Unreleased (in this build)` section. Fetch failures return `source: "unavailable"` with `error` rather than an error status; results are cached per (from, to) for an hour ([#11065](https://github.com/hivecommons/hive/issues/11065)) | `pkg/dashboard/api.go:44` | | `POST` | `/api/release-channel` | Owner only | Hosted spoke self-service release-channel selector; relays `stable`/`candidate`/`edge` to the hub's existing switch-branch endpoint with the spoke dashboard-token proof, and reports the requested channel as pending until the Deployment image lands | `pkg/dashboard/api.go:65` | -| `GET` | `/api/health` | Public | Basic health probe | `pkg/dashboard/server.go:1601` | -| `GET` | `/api/health/deep` | Public | Deep health probe | `pkg/dashboard/server.go:1602` | -| `GET` | `/api/livez` | Public | Kubernetes liveness probe | `pkg/dashboard/server.go:1603` | -| `GET` | `/metrics` | Registered only when `HIVE_METRICS_ENABLED`; requires `Authorization: ****** (403 if the token is unset) | Prometheus metrics | `pkg/dashboard/server.go:1609` | -| `GET` | `/api/status` | Dashboard auth/session | Dashboard aggregate status; `labelPresets[]` (`{key,label,description,labels[],states[]}`) lists the built-in label-filter presets for the Projects cards, led by `needs-human` whose `labels[]` are the effective hard-suppress labels plus `needs-signal`, the hold labels, `stage/071-needs-author` and the reporter-trust awaiting label (#12172); accepts `?fields=a,b` for top-level selection and `?omit=repos` to drop heavy sections, and honors `Accept-Encoding: gzip`; `agents[]` includes busy-pane visibility fields (`kicksUndeliverable`, `busySince`, `lastTranscriptActivity`, `condition`, `conditionMessage`) when a Working pane cannot accept kicks; a working agent also carries `agents[].run` — the live per-run line (#14576): `{since, elapsedS, costUSD, tokens, priced, tests, filesChanged}`, the estimated spend/tokens since the kick was delivered (`lastKickAt`, falling back to `busySince`) (delta of the token collector's per-agent cumulative figure; `priced:false` when the agent has none yet), the last visible test-runner result (`pass`/`fail`/empty) and the last `N files changed` git summary (`-1` when none) parsed from the captured pane; top-level `fleetRun` `{running, hourUSD, hourPriced}` is the governor strip's `running N · $X this hour` figure; `sla` (fleet) and `repos[].sla` (per repo) carry the Delivery SLA block derived from the lifecycle timeline with no extra GitHub calls: `windows.{7d,30d}.{open_to_triage,triage_to_start,start_to_pr,pr_to_merge,open_to_merge}` as `{p50_h,p95_h,n}` (hours, nearest-rank), `history[]` of up to 30 daily buckets `{day,start_to_pr_p50,pr_to_merge_p50,open_to_merge_p50,n_started,n_pr,n_merged}` persisted under `/data/sla-history.json`, `stale_in_progress[]` (`{number,repo,started_at,age_h,agent}` — issues carrying `hive/in-progress` longer than the agent claim TTL with no linked PR), `stale_count`, `merged_7d`, `claim_ttl_s` and, on the fleet block, the effective `targets` (`start_to_pr_h`, `pr_to_merge_h`, `open_to_merge_h`); `staleSince` and `repos[].countsStale` / `countsStaleSince` mark totals served from last-good figures — the previous enumeration (#13382) or the ForgeState cache's last-good counts (#13376); `ci_failure_signals` `{count, last, kicks, unmatched}` is the webhook CI-failure signal store — distinct red (repo, head, check) signals retained, the most recent one `{repo, number, head_sha, check, conclusion, details_url, agent, at}`, webhook-triggered kicks/nudges since boot, and failure deliveries whose head matched no open PR; `hotspots` `{count, actionable, filed}` is the merge-hotspot advisor's one-line summary (files at/above the thresholds, those with a split recommendation, those with a modularize issue filed), absent when the advisor is not wired — details on `GET /api/hotspots`; `writeback.dedupe` `{enabled, dedupe_same_item, dedupe_burst, rate_capped, hourly_cap, burst_items, burst_window_s, same_item_ttl_s}` is the write-back gate's content layer — the effective `writeback.dedupe.*` settings and the last-hour counts of writes held as `duplicate`, `burst` and `rate-capped` (each also listed under `GET /api/writeback/suppressed`) | `pkg/dashboard/server.go:1614` | -| `GET` | `/api/status/summary` | Dashboard auth/session | Compact agent/governor/budget status summary for pollers; honors `Accept-Encoding: gzip` | `pkg/dashboard/server.go:1615` | -| `GET` | `/api/overview/issues.csv` | Dashboard auth/session | Cached Overview issue-band export as browser-compatible CSV; filters `band`, `repo`/`repos`, `stale`, and `held` are ANDed. | `pkg/dashboard/server.go:1616` | -| `GET` | `/api/overview/issues.json` | Dashboard auth/session | Cached Overview issue-band export as typed JSON with `bands[]` metadata and row fields matching the CSV columns. | `pkg/dashboard/server.go:1617` | -| `GET` | `/api/overview/prs.csv` | Dashboard auth/session | Cached Overview PR-band export as browser-compatible CSV; filters `band`, `repo`/`repos`, `stale`, and `held` are ANDed. | `pkg/dashboard/server.go:1618` | -| `GET` | `/api/overview/prs.json` | Dashboard auth/session | Cached Overview PR-band export as typed JSON with `bands[]` metadata and row fields matching the CSV columns. | `pkg/dashboard/server.go:1619` | -| `GET` | `/api/events` | Dashboard auth/session | Server-sent event stream | `pkg/dashboard/server.go:1620` | +| `GET` | `/api/health` | Public | Basic health probe | `pkg/dashboard/server.go:1606` | +| `GET` | `/api/health/deep` | Public | Deep health probe | `pkg/dashboard/server.go:1607` | +| `GET` | `/api/livez` | Public | Kubernetes liveness probe | `pkg/dashboard/server.go:1608` | +| `GET` | `/metrics` | Registered only when `HIVE_METRICS_ENABLED`; requires `Authorization: ****** (403 if the token is unset) | Prometheus metrics | `pkg/dashboard/server.go:1614` | +| `GET` | `/api/status` | Dashboard auth/session | Dashboard aggregate status; `labelPresets[]` (`{key,label,description,labels[],states[]}`) lists the built-in label-filter presets for the Projects cards, led by `needs-human` whose `labels[]` are the effective hard-suppress labels plus `needs-signal`, the hold labels, `stage/071-needs-author` and the reporter-trust awaiting label (#12172); accepts `?fields=a,b` for top-level selection and `?omit=repos` to drop heavy sections, and honors `Accept-Encoding: gzip`; `agents[]` includes busy-pane visibility fields (`kicksUndeliverable`, `busySince`, `lastTranscriptActivity`, `condition`, `conditionMessage`) when a Working pane cannot accept kicks; a working agent also carries `agents[].run` — the live per-run line (#14576): `{since, elapsedS, costUSD, tokens, priced, tests, filesChanged}`, the estimated spend/tokens since the kick was delivered (`lastKickAt`, falling back to `busySince`) (delta of the token collector's per-agent cumulative figure; `priced:false` when the agent has none yet), the last visible test-runner result (`pass`/`fail`/empty) and the last `N files changed` git summary (`-1` when none) parsed from the captured pane; top-level `fleetRun` `{running, hourUSD, hourPriced}` is the governor strip's `running N · $X this hour` figure; `sla` (fleet) and `repos[].sla` (per repo) carry the Delivery SLA block derived from the lifecycle timeline with no extra GitHub calls: `windows.{7d,30d}.{open_to_triage,triage_to_start,start_to_pr,pr_to_merge,open_to_merge}` as `{p50_h,p95_h,n}` (hours, nearest-rank), `history[]` of up to 30 daily buckets `{day,start_to_pr_p50,pr_to_merge_p50,open_to_merge_p50,n_started,n_pr,n_merged}` persisted under `/data/sla-history.json`, `stale_in_progress[]` (`{number,repo,started_at,age_h,agent}` — issues carrying `hive/in-progress` longer than the agent claim TTL with no linked PR), `stale_count`, `merged_7d`, `claim_ttl_s` and, on the fleet block, the effective `targets` (`start_to_pr_h`, `pr_to_merge_h`, `open_to_merge_h`); `staleSince` and `repos[].countsStale` / `countsStaleSince` mark totals served from last-good figures — the previous enumeration (#13382) or the ForgeState cache's last-good counts (#13376); `ci_failure_signals` `{count, last, kicks, unmatched}` is the webhook CI-failure signal store — distinct red (repo, head, check) signals retained, the most recent one `{repo, number, head_sha, check, conclusion, details_url, agent, at}`, webhook-triggered kicks/nudges since boot, and failure deliveries whose head matched no open PR; `hotspots` `{count, actionable, filed}` is the merge-hotspot advisor's one-line summary (files at/above the thresholds, those with a split recommendation, those with a modularize issue filed), absent when the advisor is not wired — details on `GET /api/hotspots`; `writeback.dedupe` `{enabled, dedupe_same_item, dedupe_burst, rate_capped, hourly_cap, burst_items, burst_window_s, same_item_ttl_s}` is the write-back gate's content layer — the effective `writeback.dedupe.*` settings and the last-hour counts of writes held as `duplicate`, `burst` and `rate-capped` (each also listed under `GET /api/writeback/suppressed`) | `pkg/dashboard/server.go:1619` | +| `GET` | `/api/status/summary` | Dashboard auth/session | Compact agent/governor/budget status summary for pollers; honors `Accept-Encoding: gzip` | `pkg/dashboard/server.go:1620` | +| `GET` | `/api/overview/issues.csv` | Dashboard auth/session | Cached Overview issue-band export as browser-compatible CSV; filters `band`, `repo`/`repos`, `stale`, and `held` are ANDed. | `pkg/dashboard/server.go:1621` | +| `GET` | `/api/overview/issues.json` | Dashboard auth/session | Cached Overview issue-band export as typed JSON with `bands[]` metadata and row fields matching the CSV columns. | `pkg/dashboard/server.go:1622` | +| `GET` | `/api/overview/prs.csv` | Dashboard auth/session | Cached Overview PR-band export as browser-compatible CSV; filters `band`, `repo`/`repos`, `stale`, and `held` are ANDed. | `pkg/dashboard/server.go:1623` | +| `GET` | `/api/overview/prs.json` | Dashboard auth/session | Cached Overview PR-band export as typed JSON with `bands[]` metadata and row fields matching the CSV columns. | `pkg/dashboard/server.go:1624` | +| `GET` | `/api/events` | Dashboard auth/session | Server-sent event stream | `pkg/dashboard/server.go:1625` | | `GET` | `/api/swarm` | Dashboard auth/session | Current swarm status: display name, duration, active repo, expiry, persisted prep metrics when available, and idle-unlock fields. | `pkg/dashboard/swarm.go:310` | | `POST` | `/api/swarm` | Owner only | Start a 24h repo swarm for a configured repo, returning 409 when another swarm is active and 423 when a previous swarm keeps the next swarm locked until enough agents are idle unless body `{"repo":"owner/name","force":true}` is used; saves the active record before repo prep, persists prep metrics, and announces the start to Discord when configured. | `pkg/dashboard/swarm.go:311` | | `DELETE` | `/api/swarm` | Owner only | End the active swarm, score issues closed and PRs merged in the window, append it to history, and announce the result to Discord when configured. | `pkg/dashboard/swarm.go:312` | diff --git a/src/docs/api-reference/snapshots-and-style.md b/src/docs/api-reference/snapshots-and-style.md index 6d6cf200ef..1383b88064 100644 --- a/src/docs/api-reference/snapshots-and-style.md +++ b/src/docs/api-reference/snapshots-and-style.md @@ -6,7 +6,7 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f | Method | Path | Auth | Purpose | Source | |---|---|---|---|---| | `GET` | `/api/style` | Public | Sanitized custom dashboard CSS | `pkg/dashboard/api.go:45` | -| `GET` | `/branding/custom.css` | Dashboard auth/session | Operator branding stylesheet override, read per request (see [branding](../branding.md)) | `pkg/dashboard/server.go:1681` | +| `GET` | `/branding/custom.css` | Dashboard auth/session | Operator branding stylesheet override, read per request (see [branding](../branding.md)) | `pkg/dashboard/server.go:1686` | | `GET` | `/api/snapshot/frame-ancestors` | Public | Snapshot framing allowlist | `pkg/dashboard/api.go:78` | | `GET` | `/api/snapshot` | Public | Snapshot data | `pkg/dashboard/api.go:79` | | `GET` | `/snapshot` | Public | Public read-only snapshot page | `pkg/dashboard/api.go:80` | diff --git a/src/docs/dashboard-copy-inventory.md b/src/docs/dashboard-copy-inventory.md index b16d4052a1..80f9ecfb4a 100644 --- a/src/docs/dashboard-copy-inventory.md +++ b/src/docs/dashboard-copy-inventory.md @@ -63,6 +63,7 @@ The new hover, verbatim (title line omitted): | Confirm: Approve — let hive merge | dialog | 62 | 49 | same | | ⋯ menu hints (`stageTrackerLeadActions` → `ham-menu-hint`) | ⋯ menu | server consequences (11–31 each) | server consequences (≤ 12 each) | Go budget test | | Toasts (`STAGE_TRACKER_ACTING_CAPTIONS`, acted labels) | toast | 2–4 each | unchanged | — | +| Settings → Features → Auto-merge → "Merge only on current base" help (`renderGovFeatures`, `config-features.js`) and the Repos-tab override row / repo-card `current-base` chip ([#15335](https://github.com/hivecommons/hive/issues/15335)) | settingHelpMark popover, checkbox label, chip hover | — (new) | 56 (help), 5 (row label), 1 (chip) | `TestCurrentBaseSettingsMarkupNodeGuard` | ## Totals diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index 1b76bee651..3a01392da8 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -428,6 +428,7 @@ One card per repository Hive looks after, listing its open issues and pull reque - The repositories Hive watches are set in **Settings → Projects**. - `project.forge` (or a repo's `project.repo_policies[].forge` / `forge_url` override) and the `gitlab:` or `gitea:` instance URL set the host label and links. See [Forges](integrations/forges.md). - The `dashboard.issue_bands` settings change the band rules. +- **Merge only on current base** ([#15335](https://github.com/hivecommons/hive/issues/15335)). A green `current-base` chip in the card header means the hive only merges a pull request there once its head contains the current base tip; a green head tested on an older base is updated with GitHub update-branch and merges when CI is green on the new head. The hive-wide default is the **Merge only on current base** switch under **Settings → Features → Auto-merge** (`auto_merge.require_current_base_default`, off by default; help text: "OFF by default. Before auto-merging in any lane, require the PR head to contain the current base tip; a green head tested on an older base is updated with GitHub update-branch and merges once CI is green on the new head. Costs one compare call per merge candidate. Per-repo overrides live on the repo card."). Each row under **Settings → Repos** carries the per-repo override — the **Merge only on current base** checkbox with an *inherits* marker, or an **inherit** button when the repo has its own value — written as `auto_merge.require_current_base` (on, also strict: a head the App cannot update is parked) or `auto_merge.skip_current_base` (off). `/api/status` carries the effective value per repository as `requireCurrentBase`. - See [Repository card legend, issue bands, and PR bands](dashboard.md#repository-card-legend-issue-bands-and-pr-bands). ## ACMM Eval diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index c41445720c..8610f1725a 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -430,9 +430,9 @@ advanced into the merge path. | `auto_merge.allow_unprotected_base` | deprecated no-op | Accepted for compatibility only. [`hive-merge`](hive-merge.md) no longer refuses solely because a base branch has no GitHub branch protection; it may merge into any branch the App can write after positive CI evidence. | | `auto_merge.no_ci_ok` | unset (refuse) | **Merge-request watcher key, not a sweep key.** Per-repo opt-in that downgrades only the "unverified" CI verdict (zero statuses, check runs, and workflow runs) to green, for adopted repos with no CI by design. Red and pending verdicts are never downgraded (#6281). See [hive-merge.md](hive-merge.md). | | `auto_merge.human_merge_paths` | unset | Per-repo map of `owner/repo` to glob patterns (same syntax as `intent.guardrail_path_patterns`) for paths a person must merge, e.g. `Danathar/goodreads-mcp: [".claude/settings.json", ".claude/hooks/**"]`. Every App merge path honors it: the automerge sweep lanes (App self-merge, trusted-author, label-queued) and the agent merge-request relay refuse a PR that touches a listed path, add `hold`, and post one `` comment naming the path(s); a person must merge it. If the changed-file list cannot be fetched completely for a configured repo, the merge is withheld (#11038, #11039). | -| `auto_merge.require_current_base` | unset | Repo list (`owner/repo`) explicitly opted into the current-base gate in its **strict** form. The gate itself is on for every repo by default (see `require_current_base_default`): the App self-merge, trusted-author and contributor lanes only merge a head that contains the current base tip. A green head tested against an older base is updated with GitHub update-branch (a merge commit; no author commit is rewritten) and merges once CI is green on the new head, so a semantic conflict with work merged since turns that PR red instead of breaking the base ([#13634](https://github.com/hivecommons/hive/issues/13634), [#15335](https://github.com/hivecommons/hive/issues/15335)). Costs one compare call per merge candidate. Listing a repo here additionally makes it strict: a behind head the App cannot update (fork without maintainer edits, branch protection or a missing `contents: write`) is parked (`fork-not-editable` / `update-branch`) rather than merged as tested. | -| `auto_merge.require_current_base_default` | `true` | Fleet-wide default of the current-base gate for repos in neither `require_current_base` nor `skip_current_base`. On a default-gated repo a behind head the App cannot update merges as it was tested, with one WARN per PR (`automerge current-base gate: … merging as tested`), so fork-heavy repos are not parked wholesale. Set `false` to return to opt-in only. | -| `auto_merge.skip_current_base` | unset | Repo list (`owner/repo`) opted **out** of the current-base gate: a green head there merges even if the base has moved (the pre-#15335 behaviour). An explicit `require_current_base` entry wins over this list. | +| `auto_merge.require_current_base` | unset | Repo list (`owner/repo`) with an explicit **on** override for the current-base merge gate (Settings → Repos → "Merge only on current base"). On a gated repo the App self-merge, trusted-author and contributor lanes only merge a head that contains the current base tip. A green head tested against an older base is updated with GitHub update-branch (a merge commit; no author commit is rewritten) and merges once CI is green on the new head, so a semantic conflict with work merged since turns that PR red instead of breaking the base ([#13634](https://github.com/hivecommons/hive/issues/13634), [#15335](https://github.com/hivecommons/hive/issues/15335)). Costs one compare call per merge candidate. Listing a repo here is also **strict**: a behind head the App cannot update (fork without maintainer edits, branch protection or a missing `contents: write`) is parked (`fork-not-editable` / `update-branch`) rather than merged as tested. Wins over `skip_current_base` and over the default. | +| `auto_merge.require_current_base_default` | `false` | Hive-wide default of the current-base gate for repos in neither `require_current_base` nor `skip_current_base` (Settings → Features → Auto-merge → "Merge only on current base"). **Off** by default: the merge train already update-branches overlapping siblings, so the gate is being soaked per repo (hive's own hive first, via `require_current_base`) before any hive turns it on everywhere. When `true`, a behind head the App cannot update merges as it was tested, with one WARN per PR (`automerge current-base gate: … merging as tested`), so fork-heavy repos are not parked wholesale. | +| `auto_merge.skip_current_base` | unset | Repo list (`owner/repo`) with an explicit **off** override for the current-base gate (Settings → Repos → "Merge only on current base" unchecked): a green head there merges even if the base has moved, whatever `require_current_base_default` says. An explicit `require_current_base` entry wins over this list. | | `auto_merge.merge_forward_trusted_human` | unset (off) | Repo list (`owner/repo`) where a `role/trusted` + `author/human` PR on a same-repo branch that GitHub reports as conflicting (`dirty`) gets the base merged into its head as one App-authored, signed-off merge commit via the GitHub merges API (no human commit is rewritten), then merges once CI is green on the new head. A real conflict pushes nothing and posts one `` note naming the files both sides changed. Fork heads are never written. Attempted once per head (#13636). | | `auto_merge.merge_train.enabled` | `true` | Conflict-aware merge train in every automerge lane (hive, trusted-author, contributor) ([#15117](https://github.com/hivecommons/hive/issues/15117)). Each sweep groups the open approved / mergeable-pending PRs of one repo+base by overlapping changed files (`GET /pulls/{n}/files`, cached per head SHA) and lets ONE front per group merge — the clean-mergeable PR approved earliest — while the others wait at stage/080 with lane reason `merge-train:queued-behind#:/:…` (tracker pill "In merge queue · 3 of 4 · ~4m", never a human stage, never `needs-rebase` as a human flag). The moment the front merges, every sibling whose branch is merely `behind` gets `PUT /pulls/{n}/update-branch`; a `dirty` one is handed to the fixer's rebase-resolve episode (`requested_by: merge-train`, the shared two-attempt guard of [#15104](https://github.com/hivecommons/hive/pull/15104); the fixer router still requires a head the hive can push to, so a fork without maintainer edits stays on the plain `conflicting` path for a person). A head the lane last saw blocked on its own (red required check, terminal hold, permanent merge refusal) never fronts, and a group whose best member is blocked imposes no ordering (fail-open) — nobody waits behind a PR that is not moving. One INFO line `merge train` per order change, not per cycle. The queue carries one PR per issue: when two open PRs declare the same `Fixes #N`, the sweep keeps one (green first, then the earlier-opened) and holds the other with lane reason `merge-train:duplicate-of#:/0:0/0:` (tracker pill "Duplicate of #15402 · needs a pick"; *Let hive decide* supersedes, [#15395](https://github.com/hivecommons/hive/issues/15395)). `false` restores independent per-PR evaluation. A PR GitHub reports conflicting on its own, or one at stage/072 returned-to-contributor (label or stage record), is never a member nor counted in the train's size and draws no train idle comment; a conflicting PR rides only while the train itself is repairing it (its rebase requested behind a merged front, loop guard not spent) ([#15395](https://github.com/hivecommons/hive/issues/15395)). | | `auto_merge.merge_train.max_rebase_attempts` | `2` | Loop guard: how many rebase-resolve requests the train makes for one PR behind one front. Past it the PR moves to stage/085 with the pill "Needs human decision · rebase failed twice" and the decision option "Rebase, then merge as maintainer". | diff --git a/src/pkg/config/automerge_current_base_test.go b/src/pkg/config/automerge_current_base_test.go index 2213fc69c4..3b62976bcb 100644 --- a/src/pkg/config/automerge_current_base_test.go +++ b/src/pkg/config/automerge_current_base_test.go @@ -1,12 +1,18 @@ package config -import "testing" +import ( + "reflect" + "testing" +) +// TestRequireCurrentBaseFor pins the effective-value table of the current-base +// gate (hivecommons/hive#15335): explicit lists beat the default, the explicit +// "on" list beats the skip list, and the unset default is OFF. func TestRequireCurrentBaseFor(t *testing.T) { - off := false listed := AutoMergeConfig{RequireCurrentBase: []string{" HiveCommons/Hive ", ""}} skipped := AutoMergeConfig{SkipCurrentBase: []string{"Acme/Legacy"}} - defaultOff := AutoMergeConfig{RequireCurrentBaseDefault: &off, RequireCurrentBase: []string{"hivecommons/hive"}} + defaultOn := AutoMergeConfig{RequireCurrentBaseDefault: boolPtr(true), SkipCurrentBase: []string{"acme/legacy"}} + defaultOff := AutoMergeConfig{RequireCurrentBaseDefault: boolPtr(false), RequireCurrentBase: []string{"hivecommons/hive"}} both := AutoMergeConfig{RequireCurrentBase: []string{"acme/widget"}, SkipCurrentBase: []string{"acme/widget"}} tests := []struct { name string @@ -14,16 +20,17 @@ func TestRequireCurrentBaseFor(t *testing.T) { repo string want bool }{ - {"unset defaults on", AutoMergeConfig{}, "hivecommons/hive", true}, - {"unlisted repo defaults on", listed, "acme/widget", true}, + {"unset defaults off", AutoMergeConfig{}, "hivecommons/hive", false}, + {"unlisted repo defaults off", listed, "acme/widget", false}, {"listed case-insensitive", listed, "hivecommons/hive", true}, {"listed with spaces", listed, " HIVECOMMONS/HIVE ", true}, {"empty repo", listed, "", false}, {"skip list opts out", skipped, "acme/legacy", false}, - {"skip list leaves others on", skipped, "acme/widget", true}, - {"default false turns unlisted off", defaultOff, "acme/widget", false}, - {"default false keeps listed on", defaultOff, "hivecommons/hive", true}, - {"explicit list beats skip list", both, "acme/widget", true}, + {"default on covers unlisted", defaultOn, "acme/widget", true}, + {"skip beats default on", defaultOn, "acme/legacy", false}, + {"default off keeps unlisted off", defaultOff, "acme/widget", false}, + {"explicit on beats default off", defaultOff, "hivecommons/hive", true}, + {"explicit on beats skip", both, "acme/widget", true}, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { @@ -35,14 +42,39 @@ func TestRequireCurrentBaseFor(t *testing.T) { } func TestRequireCurrentBaseStrictFor(t *testing.T) { - cfg := AutoMergeConfig{RequireCurrentBase: []string{"HiveCommons/Hive"}} + cfg := AutoMergeConfig{RequireCurrentBase: []string{"HiveCommons/Hive"}, RequireCurrentBaseDefault: boolPtr(true)} if !cfg.RequireCurrentBaseStrictFor("hivecommons/hive") { t.Fatal("listed repo must be strict") } if cfg.RequireCurrentBaseStrictFor("acme/widget") { t.Fatal("default-gated repo must not be strict") } - if (AutoMergeConfig{}).RequireCurrentBaseStrictFor("hivecommons/hive") { - t.Fatal("unset list must not make any repo strict") +} + +func TestCurrentBaseOverrideRoundTrip(t *testing.T) { + var a AutoMergeConfig + if a.CurrentBaseOverrideFor("acme/widget") != nil { + t.Fatal("fresh config must inherit") + } + a.SetCurrentBaseOverride("acme/widget", boolPtr(true)) + a.SetCurrentBaseOverride("acme/legacy", boolPtr(false)) + if v := a.CurrentBaseOverrideFor("ACME/widget"); v == nil || !*v { + t.Fatalf("override(widget) = %v, want on", v) + } + if v := a.CurrentBaseOverrideFor("acme/legacy"); v == nil || *v { + t.Fatalf("override(legacy) = %v, want off", v) + } + // Flipping moves the repo between the lists rather than leaving it in both. + a.SetCurrentBaseOverride("Acme/Widget", boolPtr(false)) + if !reflect.DeepEqual(a.RequireCurrentBase, []string(nil)) || !reflect.DeepEqual(a.SkipCurrentBase, []string{"acme/legacy", "Acme/Widget"}) { + t.Fatalf("after flip: require=%v skip=%v", a.RequireCurrentBase, a.SkipCurrentBase) + } + a.SetCurrentBaseOverride("acme/widget", nil) + a.SetCurrentBaseOverride("acme/legacy", nil) + if a.RequireCurrentBase != nil || a.SkipCurrentBase != nil { + t.Fatalf("after clearing: require=%v skip=%v, want both empty", a.RequireCurrentBase, a.SkipCurrentBase) + } + if a.CurrentBaseOverrideFor("acme/widget") != nil { + t.Fatal("cleared repo must inherit") } } diff --git a/src/pkg/config/config.go b/src/pkg/config/config.go index 9d18c528bf..c55e7bab46 100644 --- a/src/pkg/config/config.go +++ b/src/pkg/config/config.go @@ -8033,30 +8033,33 @@ type AutoMergeConfig struct { // lives in the merge sweeps. HumanMergePaths map[string][]string `yaml:"human_merge_paths,omitempty" json:"human_merge_paths,omitempty"` // RequireCurrentBase lists owner/repo names whose automerge sweeps only - // merge a PR head that already contains the current base branch tip. - // A head that is green but was tested against an older base is updated - // (GitHub update-branch, a merge commit) and merged once CI is green on - // the new head, so a semantic conflict with anything merged since shows - // up as red CI instead of a broken base. + // merge a PR head that already contains the current base branch tip + // (hivecommons/hive#13634). A head that is green but was tested against + // an older base is updated (GitHub update-branch, a merge commit) and + // merged once CI is green on the new head, so a semantic conflict with + // anything merged since shows up as red CI instead of a broken base. // - // Since hivecommons/hive#15335 the gate is ON for every repo by default - // (RequireCurrentBaseDefault); this list is the STRICT form: a listed + // This list is the explicit per-repo "on" and its STRICT form: a listed // repo never falls back to merging an un-updated head, even when the App // cannot update the branch (fork head without maintainer edits, branch - // protection or a missing contents:write). Repos covered only by the - // default merge the green head as tested in that case, with one WARN per - // PR, so a fork-heavy repo is not parked wholesale by the default. + // protection or a missing contents:write). It wins over SkipCurrentBase + // and RequireCurrentBaseDefault. The dashboard's per-repo override + // ("Merge only on current base: inherit / on / off") writes this list and + // SkipCurrentBase (hivecommons/hive#15335). RequireCurrentBase []string `yaml:"require_current_base,omitempty" json:"require_current_base,omitempty"` - // RequireCurrentBaseDefault is the fleet-wide default for the gate above - // on repos that appear in neither RequireCurrentBase nor - // SkipCurrentBase. nil/unset means true (hivecommons/hive#15335: a - // stale-green merge broke v5 for every open PR for 20 minutes because the - // repo was not listed). `false` restores the opt-in-only behaviour. + // RequireCurrentBaseDefault is the hive-wide default of the gate above + // for repos in neither RequireCurrentBase nor SkipCurrentBase. nil/unset + // means OFF (hivecommons/hive#15335: the owner kept the fleet default off + // — the merge train already update-branches overlapping siblings — and + // soaks the gate per repo first). The Features dialog toggle "Merge only + // on current base" writes it. A repo gated only by this default merges a + // behind head the App cannot update as tested, with one WARN per PR, so + // turning the default on does not park every fork PR. RequireCurrentBaseDefault *bool `yaml:"require_current_base_default,omitempty" json:"require_current_base_default,omitempty"` - // SkipCurrentBase lists owner/repo names opted OUT of the current-base - // gate: a green head there merges even if the base has moved (the - // pre-#15335 behaviour). An explicit RequireCurrentBase entry wins over - // this list. + // SkipCurrentBase lists owner/repo names explicitly opted OUT of the + // current-base gate: a green head there merges even if the base has + // moved, whatever RequireCurrentBaseDefault says. A RequireCurrentBase + // entry for the same repo wins over this list. SkipCurrentBase []string `yaml:"skip_current_base,omitempty" json:"skip_current_base,omitempty"` // MergeForwardTrustedHuman lists owner/repo names where a role/trusted // author/human PR that GitHub reports as conflicting ("dirty") gets the @@ -8511,19 +8514,78 @@ func (a AutoMergeConfig) HumanMergePathsFor(repo string) []string { // matched case-insensitively). Resolution order: an explicit // auto_merge.require_current_base entry (on, strict), then // auto_merge.skip_current_base (off), then -// auto_merge.require_current_base_default (unset means on). +// auto_merge.require_current_base_default (unset means off). func (a AutoMergeConfig) RequireCurrentBaseFor(repo string) bool { key := strings.ToLower(strings.TrimSpace(repo)) if key == "" { return false } + if v := a.CurrentBaseOverrideFor(key); v != nil { + return *v + } + return a.CurrentBaseDefaultEnabled() +} + +// CurrentBaseDefaultEnabled reports auto_merge.require_current_base_default +// with its unset value resolved (off). +func (a AutoMergeConfig) CurrentBaseDefaultEnabled() bool { + return a.RequireCurrentBaseDefault != nil && *a.RequireCurrentBaseDefault +} + +// CurrentBaseOverrideFor returns the explicit per-repo setting of the +// current-base gate: true when repo is in auto_merge.require_current_base, +// false when it is in auto_merge.skip_current_base (and not in the former), +// nil when the repo inherits the hive-wide default. +func (a AutoMergeConfig) CurrentBaseOverrideFor(repo string) *bool { + key := strings.ToLower(strings.TrimSpace(repo)) + if key == "" { + return nil + } if repoListSet(a.RequireCurrentBase)[key] { - return true + v := true + return &v } if repoListSet(a.SkipCurrentBase)[key] { - return false + v := false + return &v + } + return nil +} + +// SetCurrentBaseOverride records the dashboard's per-repo tri-state for the +// current-base gate: true adds repo to require_current_base, false adds it +// to skip_current_base, nil removes it from both so it inherits the default. +// The repo is removed from the other list in every case, so a repo is never +// in both. repo should be owner/repo; matching is case-insensitive. +func (a *AutoMergeConfig) SetCurrentBaseOverride(repo string, value *bool) { + if a == nil { + return + } + repo = strings.TrimSpace(repo) + if repo == "" { + return + } + drop := func(list []string) []string { + out := list[:0:0] + for _, r := range list { + if !strings.EqualFold(strings.TrimSpace(r), repo) { + out = append(out, r) + } + } + if len(out) == 0 { + return nil + } + return out + } + a.RequireCurrentBase = drop(a.RequireCurrentBase) + a.SkipCurrentBase = drop(a.SkipCurrentBase) + switch { + case value == nil: + case *value: + a.RequireCurrentBase = append(a.RequireCurrentBase, repo) + default: + a.SkipCurrentBase = append(a.SkipCurrentBase, repo) } - return a.RequireCurrentBaseDefault == nil || *a.RequireCurrentBaseDefault } // RequireCurrentBaseStrictFor reports whether repo is explicitly listed in diff --git a/src/pkg/dashboard/api_config_automerge.go b/src/pkg/dashboard/api_config_automerge.go index 45b2657a07..d07602c54e 100644 --- a/src/pkg/dashboard/api_config_automerge.go +++ b/src/pkg/dashboard/api_config_automerge.go @@ -153,7 +153,11 @@ func (s *Server) handleAutoMergePut(w http.ResponseWriter, r *http.Request) { // BotTakeoverEnabled is auto_merge.bot_takeover.enabled; flat so the // dialog's plain toggle can stage it. BotTakeoverEnabled *bool `json:"bot_takeover_enabled"` - TrustedAuthors *struct { + // RequireCurrentBaseDefault is auto_merge.require_current_base_default, + // the Features toggle "Merge only on current base" (#15335). Per-repo + // overrides travel on PUT /api/config/governor/repos. + RequireCurrentBaseDefault *bool `json:"require_current_base_default"` + TrustedAuthors *struct { Enabled *bool `json:"enabled"` Repos []string `json:"repos"` RequireRole *string `json:"require_role"` @@ -290,6 +294,10 @@ func (s *Server) handleAutoMergePut(w http.ResponseWriter, r *http.Request) { v := *body.BotTakeoverEnabled cfg.AutoMerge.BotTakeover.Enabled = &v } + if body.RequireCurrentBaseDefault != nil { + v := *body.RequireCurrentBaseDefault + cfg.AutoMerge.RequireCurrentBaseDefault = &v + } if body.TrustedAuthors != nil { if body.TrustedAuthors.Enabled != nil { cfg.AutoMerge.TrustedAuthors.Enabled = *body.TrustedAuthors.Enabled @@ -401,16 +409,19 @@ func autoMergeSectionResponse(cfg *config.Config) map[string]interface{} { contributorLaneLabels = append([]string{}, config.DefaultContributorLaneExcludeLabels...) } return map[string]interface{}{ - "self_authored": selfAuthored, - "self_authored_set": am.SelfAuthored != nil, - "max_merges": am.MaxMerges, - "min_head_age": am.EffectiveMinHeadAge().String(), - "required_checks": checks, - "allow_unprotected_base": allowUnprotected, - "no_ci_ok": noCIOK, - "trusted_bot_authors": trustedBots, - "trusted_bot_authors_set": am.TrustedBotAuthors != nil, - "bot_takeover_enabled": am.BotTakeover.IsEnabled(), + "self_authored": selfAuthored, + "self_authored_set": am.SelfAuthored != nil, + "max_merges": am.MaxMerges, + "min_head_age": am.EffectiveMinHeadAge().String(), + "required_checks": checks, + "allow_unprotected_base": allowUnprotected, + "no_ci_ok": noCIOK, + "trusted_bot_authors": trustedBots, + "trusted_bot_authors_set": am.TrustedBotAuthors != nil, + "bot_takeover_enabled": am.BotTakeover.IsEnabled(), + "require_current_base_default": am.CurrentBaseDefaultEnabled(), + "require_current_base": emptyIfNilStrings(am.RequireCurrentBase), + "skip_current_base": emptyIfNilStrings(am.SkipCurrentBase), "trusted_authors": map[string]interface{}{ "enabled": ta.Enabled, "repos": trustedAuthorRepos, @@ -458,3 +469,10 @@ func normalizeAutoMergeRepoList(repos []string) []string { } return out } + +func emptyIfNilStrings(list []string) []string { + if list == nil { + return []string{} + } + return list +} diff --git a/src/pkg/dashboard/api_governor.go b/src/pkg/dashboard/api_governor.go index 01e63507a4..8f5bb2b1fc 100644 --- a/src/pkg/dashboard/api_governor.go +++ b/src/pkg/dashboard/api_governor.go @@ -71,6 +71,9 @@ func (s *Server) handleGovernorConfigGet(w http.ResponseWriter, r *http.Request) repoSelfAuthorizationHold := make(map[string]map[string]any, len(cfg.Project.Repos)) repoReporterTrustHold := make(map[string]map[string]any, len(cfg.Project.Repos)) repoLabelDriven := make(map[string]map[string]any, len(cfg.Project.Repos)) + // #15335 current-base gate: same three-way shape as #5117/#9665 + // (hive-wide default on the Features tab, per-repo override here). + repoCurrentBase := make(map[string]map[string]any, len(cfg.Project.Repos)) for _, repo := range cfg.Project.Repos { full := repo if strings.Contains(repo, "/") { @@ -90,6 +93,11 @@ func (s *Server) handleGovernorConfigGet(w http.ResponseWriter, r *http.Request) } repoReporterTrustHold[full] = rtEntry repoLabelDriven[full] = labelDrivenRepoPayload(cfg, repo) + cbEntry := map[string]any{"effective": cfg.AutoMerge.RequireCurrentBaseFor(full)} + if v := cfg.AutoMerge.CurrentBaseOverrideFor(full); v != nil { + cbEntry["value"] = *v + } + repoCurrentBase[full] = cbEntry } // hivecommons/hive#11313 label-driven approval, rendered on the Repos tab // next to the per-repo opt-in. EFFECTIVE values are sent for the defaulted @@ -191,6 +199,8 @@ func (s *Server) handleGovernorConfigGet(w http.ResponseWriter, r *http.Request) "reporterTrustHoldEnvLocked": cfg.GitHub.ReporterTrustHoldEnvOverrideSet(), "repoLabelDriven": repoLabelDriven, "labelDrivenApproval": labelDrivenApproval, + "currentBaseDefault": cfg.AutoMerge.CurrentBaseDefaultEnabled(), + "repoCurrentBase": repoCurrentBase, // Kick-list caps, rendered on the Repos tab. The EFFECTIVE values are // sent (defaults and ceiling already resolved) so the fields always // show the number actually in force rather than an empty box when the @@ -2913,6 +2923,10 @@ func (s *Server) handleGovernorRepos(w http.ResponseWriter, r *http.Request) { // knobs. Pointer-typed so absent keys mean "unchanged". RepoLabelDriven map[string]*labelDrivenRepoBody `json:"repoLabelDriven,omitempty"` LabelDrivenApproval *labelDrivenApprovalBody `json:"labelDrivenApproval,omitempty"` + // hivecommons/hive#15335 current-base gate per-repo override: + // true → auto_merge.require_current_base, false → + // auto_merge.skip_current_base, null → inherit (removed from both). + RepoCurrentBase map[string]*bool `json:"repoCurrentBase,omitempty"` // Kick-list caps. POINTER-typed so an absent key means "unchanged": // the Repos tab sends only the fields the operator actually touched, // and editing a repo must not reset the caps (or vice versa). @@ -2928,7 +2942,7 @@ func (s *Server) handleGovernorRepos(w http.ResponseWriter, r *http.Request) { // the "nothing supplied" guard must only fire when the request would change // nothing at all. capsOnly := body.MaxIssuesPerKick != nil || body.MaxPRsPerKick != nil - holdOnly := body.ReporterTrustHold != nil || body.RepoReporterTrustHold != nil || body.RepoLabelDriven != nil || body.LabelDrivenApproval != nil + holdOnly := body.ReporterTrustHold != nil || body.RepoReporterTrustHold != nil || body.RepoLabelDriven != nil || body.LabelDrivenApproval != nil || body.RepoCurrentBase != nil if len(body.Repos) == 0 && body.PrimaryRepo == nil && body.SelfAuthorizationHold == nil && body.RepoSelfAuthorizationHold == nil && !capsOnly && !holdOnly { jsonError(w, "at least one repo is required", http.StatusBadRequest) return @@ -3124,6 +3138,15 @@ func (s *Server) handleGovernorRepos(w http.ResponseWriter, r *http.Request) { if body.LabelDrivenApproval != nil { body.LabelDrivenApproval.applyTo(s.deps.Config) } + for repo, value := range body.RepoCurrentBase { + // The auto_merge lists hold owner/repo; the Repos tab may send a bare + // name for a repo of this hive's org. + full := strings.TrimSpace(repo) + if full != "" && !strings.Contains(full, "/") && strings.TrimSpace(s.deps.Config.Project.Org) != "" { + full = strings.TrimSpace(s.deps.Config.Project.Org) + "/" + full + } + s.deps.Config.AutoMerge.SetCurrentBaseOverride(full, value) + } s.deps.Config.PruneRepoPoliciesToWatched() // Applied after the repo guards (which roll back on failure) so a rejected diff --git a/src/pkg/dashboard/current_base_settings_test.go b/src/pkg/dashboard/current_base_settings_test.go new file mode 100644 index 0000000000..214c99fcae --- /dev/null +++ b/src/pkg/dashboard/current_base_settings_test.go @@ -0,0 +1,150 @@ +package dashboard + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "os/exec" + "reflect" + "strings" + "testing" + + "github.com/hivecommons/hive/pkg/governor" +) + +// hivecommons/hive#15335: the current-base merge gate is a Features toggle +// (hive-wide default, OFF unless switched on) plus a per-repo override on the +// Repos tab, and the repo card shows the effective value. + +func TestAutoMergePutRequireCurrentBaseDefault(t *testing.T) { + s := covApiServer(t) + if s.deps.Config.AutoMerge.CurrentBaseDefaultEnabled() { + t.Fatal("current-base default must be OFF out of the box") + } + rec := doPut(s, "/api/config/auto-merge", map[string]any{"require_current_base_default": true}) + if rec.Code != http.StatusOK { + t.Fatalf("auto-merge PUT: %d — %s", rec.Code, rec.Body.String()) + } + if !s.deps.Config.AutoMerge.CurrentBaseDefaultEnabled() { + t.Fatal("require_current_base_default=true not applied") + } + var am map[string]any + if err := json.Unmarshal(rec.Body.Bytes(), &am); err != nil { + t.Fatal(err) + } + if am["require_current_base_default"] != true { + t.Fatalf("response require_current_base_default = %v", am["require_current_base_default"]) + } + for _, k := range []string{"require_current_base", "skip_current_base"} { + if list, ok := am[k].([]any); !ok || len(list) != 0 { + t.Errorf("response %s = %v, want empty list", k, am[k]) + } + } + // A PUT that omits the key leaves it alone (pointer semantics). + rec = doPut(s, "/api/config/auto-merge", map[string]any{"bot_takeover_enabled": true}) + if rec.Code != http.StatusOK || !s.deps.Config.AutoMerge.CurrentBaseDefaultEnabled() { + t.Fatalf("omitted key changed the default: code=%d enabled=%v", rec.Code, s.deps.Config.AutoMerge.CurrentBaseDefaultEnabled()) + } +} + +func TestHandleGovernorRepos_CurrentBaseOverrides(t *testing.T) { + srv := newFullServer(t) + srv.deps.Config.Project.Org = "testorg" + srv.deps.Config.Project.Repos = []string{"alpha", "beta", "gamma"} + srv.deps.Config.Project.PrimaryRepo = "alpha" + + // An override-only save must not be rejected as "no repos". + w := httptest.NewRecorder() + srv.handleGovernorRepos(w, ownerPUT(t, "/api/config/governor/repos", `{"repoCurrentBase":{"beta":true,"gamma":false}}`)) + if w.Code != http.StatusOK { + t.Fatalf("code = %d, body = %s", w.Code, w.Body.String()) + } + am := &srv.deps.Config.AutoMerge + if got := am.RequireCurrentBase; !reflect.DeepEqual(got, []string{"testorg/beta"}) { + t.Errorf("require_current_base = %v, want [testorg/beta]", got) + } + if got := am.SkipCurrentBase; !reflect.DeepEqual(got, []string{"testorg/gamma"}) { + t.Errorf("skip_current_base = %v, want [testorg/gamma]", got) + } + if am.RequireCurrentBaseFor("testorg/alpha") || !am.RequireCurrentBaseFor("testorg/beta") || am.RequireCurrentBaseFor("testorg/gamma") { + t.Error("effective values after override save are wrong") + } + + result := decodeGovernorConfigGet(t, srv) + if result["currentBaseDefault"] != false { + t.Errorf("GET currentBaseDefault = %v, want false", result["currentBaseDefault"]) + } + repoMap := result["repoCurrentBase"].(map[string]any) + beta := repoMap["testorg/beta"].(map[string]any) + if beta["value"] != true || beta["effective"] != true { + t.Errorf("beta entry = %v, want value=true effective=true", beta) + } + gamma := repoMap["testorg/gamma"].(map[string]any) + if gamma["value"] != false || gamma["effective"] != false { + t.Errorf("gamma entry = %v, want value=false effective=false", gamma) + } + alpha := repoMap["testorg/alpha"].(map[string]any) + if _, hasValue := alpha["value"]; hasValue || alpha["effective"] != false { + t.Errorf("alpha entry = %v, want no value (inherits) and effective=false", alpha) + } + + // Flipping an override moves the repo between the two lists; null clears it. + w = httptest.NewRecorder() + srv.handleGovernorRepos(w, ownerPUT(t, "/api/config/governor/repos", `{"repoCurrentBase":{"beta":false,"gamma":null}}`)) + if w.Code != http.StatusOK { + t.Fatalf("flip code = %d, body = %s", w.Code, w.Body.String()) + } + if len(am.RequireCurrentBase) != 0 { + t.Errorf("require_current_base = %v, want empty after flip", am.RequireCurrentBase) + } + if got := am.SkipCurrentBase; !reflect.DeepEqual(got, []string{"testorg/beta"}) { + t.Errorf("skip_current_base = %v, want [testorg/beta]", got) + } + if v := am.CurrentBaseOverrideFor("testorg/gamma"); v != nil { + t.Errorf("gamma override = %v, want cleared", *v) + } +} + +func TestStatusRepoExposesRequireCurrentBase(t *testing.T) { + s := covApiServer(t) + s.deps.Config.Project.Org = "testorg" + s.deps.Config.Project.Repos = []string{"alpha", "beta"} + s.deps.Config.AutoMerge.RequireCurrentBase = []string{"testorg/beta"} + repos := buildRepos(s.deps.Config, nil, governor.State{}) + got := map[string]bool{} + for _, r := range repos { + got[r.Name] = r.RequireCurrentBase + } + if got["alpha"] || !got["beta"] { + t.Fatalf("requireCurrentBase per repo = %v, want alpha=false beta=true", got) + } +} + +func TestCurrentBaseSettingsMarkupNodeGuard(t *testing.T) { + html := indexHTML(t) + script := ` +const fs = require('fs'); +const html = fs.readFileSync(0, 'utf8'); +function fail(msg) { console.error(msg); process.exit(1); } +const features = html.match(/function renderGovFeatures\([\s\S]*?\n function /); +if (!features) fail('renderGovFeatures not found'); +const f = features[0]; +const sw = f.match(/
<\/div>\s*Merge only on current base /); +if (!sw) fail('Features toggle "Merge only on current base" bound to auto-merge/require_current_base_default not found'); +if (!f.includes("yamlHint('auto_merge.require_current_base_default')")) fail('toggle lacks its YAML hint'); +if (!f.includes('OFF by default. Before auto-merging in any lane, require the PR head to contain the current base tip')) fail('toggle help text missing'); +if (!f.includes('Per-repo overrides live on the repo card.')) fail('toggle help text does not point at the per-repo override'); +if (!/data-change-action="toggleRepoCurrentBase"[^>]*data-arg-types="s,c"> Merge only on current base<\/label>/.test(html)) fail('Repos tab per-repo override checkbox missing'); +if (!/data-action="clearRepoCurrentBaseOverride"/.test(html)) fail('Repos tab inherit button missing'); +if (!/class="repo-current-base-pill"/.test(html)) fail('repo card current-base chip missing'); +` + cmd := exec.Command("node", "-e", script) + cmd.Stdin = strings.NewReader(html) + out, err := cmd.CombinedOutput() + if err != nil { + if strings.Contains(err.Error(), "executable file not found") { + t.Skip("node is not installed") + } + t.Fatalf("node current-base settings guard failed: %v\n%s", err, string(out)) + } +} diff --git a/src/pkg/dashboard/server.go b/src/pkg/dashboard/server.go index 5f67f89a78..d5494a1cc2 100644 --- a/src/pkg/dashboard/server.go +++ b/src/pkg/dashboard/server.go @@ -1214,6 +1214,11 @@ type FrontendRepo struct { PausedAt string `json:"pausedAt,omitempty"` PauseReason string `json:"pauseReason,omitempty"` AutoMerge bool `json:"autoMerge"` + // RequireCurrentBase is the effective current-base gate for this repo + // (auto_merge.require_current_base / skip_current_base over the hive-wide + // default, hivecommons/hive#15335); the repo card shows a "current-base" + // chip when it is on. + RequireCurrentBase bool `json:"requireCurrentBase,omitempty"` // Upstream is the upstream a fork repo follows (hivecommons/hive#11433): // the repo's upstream_watch entry, resolved to the fork parent once the // watch has run. Empty for a repo that is not in the watch. UpstreamWatchOn diff --git a/src/pkg/dashboard/settings_parity_allowlist.txt b/src/pkg/dashboard/settings_parity_allowlist.txt index e3b119b023..6013cc9a6a 100644 --- a/src/pkg/dashboard/settings_parity_allowlist.txt +++ b/src/pkg/dashboard/settings_parity_allowlist.txt @@ -160,10 +160,9 @@ auto_merge.merge_train.enabled # conflict-aware merge train (#15117); yaml-only auto_merge.merge_train.max_rebase_attempts # merge train rebase loop guard (#15117); yaml-only auto_merge.no_ci_ok[] # TODO #11854 auto_merge.repos..required_checks[] # TODO #11854 -auto_merge.require_current_base[] # TODO #11854 -auto_merge.require_current_base_default # current-base gate fleet default (#15335); yaml-only +auto_merge.require_current_base[] # current-base gate per-repo "on" override, written by the Repos tab (#15335) auto_merge.required_checks[] # TODO #11854 -auto_merge.skip_current_base[] # current-base gate per-repo opt-out (#15335); yaml-only +auto_merge.skip_current_base[] # current-base gate per-repo "off" override, written by the Repos tab (#15335) auto_merge.squash_only[] # merge-method policy; yaml-only auto_merge.trusted_authors.exclude_labels[] # TODO #11854 auto_merge.trusted_authors.repos[] # TODO #11854 diff --git a/src/pkg/dashboard/static-src/css/repos.css b/src/pkg/dashboard/static-src/css/repos.css index 37b4637efc..cb28002577 100644 --- a/src/pkg/dashboard/static-src/css/repos.css +++ b/src/pkg/dashboard/static-src/css/repos.css @@ -84,6 +84,7 @@ .repo-swarm-btn { flex: 0 0 auto; font-size: var(--fs-2xs); font-weight: 700; line-height: 1; padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill); white-space: nowrap; cursor: pointer; border: 1px solid color-mix(in srgb, var(--amber) 40%, var(--border)); background: color-mix(in srgb, var(--amber) 10%, transparent); color: var(--amber); opacity: 0.85; transition: opacity 0.15s, color 0.15s, border-color 0.15s; } .repo-swarm-btn:hover { opacity: 1; border-color: var(--amber); } .repo-swarm-btn[data-busy="1"] { opacity: 0.5; cursor: default; } + .repo-current-base-pill { flex: 0 0 auto; font-size: var(--fs-2xs); font-weight: 700; letter-spacing: 0.02em; line-height: 1; padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill); white-space: nowrap; border: 1px solid color-mix(in srgb, var(--green) 45%, transparent); background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); cursor: help; } .repo-swarm-pill { flex: 0 0 auto; font-size: var(--fs-2xs); font-weight: 800; letter-spacing: 0.02em; line-height: 1; padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill); white-space: nowrap; text-transform: uppercase; border: 1px solid color-mix(in srgb, var(--amber) 55%, transparent); background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); } .swarm-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(12rem, 20rem); gap: var(--sp-5); align-items: start; margin: var(--sp-0) var(--sp-0) var(--sp-5); padding: var(--sp-5); border: 1px solid var(--border); border-radius: var(--r-lg); background: color-mix(in srgb, var(--amber) 5%, var(--surface)); } .swarm-title { font-weight: 800; color: var(--amber); margin-bottom: var(--sp-2); } diff --git a/src/pkg/dashboard/static-src/js/config-features.js b/src/pkg/dashboard/static-src/js/config-features.js index 9c35791c7a..57154b8833 100644 --- a/src/pkg/dashboard/static-src/js/config-features.js +++ b/src/pkg/dashboard/static-src/js/config-features.js @@ -472,6 +472,10 @@
Sync lane-authored contributor fork PRs with base ${settingHelpMark('review-swarm', 'configuration', 'Sync lane-authored contributor fork PRs with base', `OFF by default. Owner gate for review.contributor_prs.base_sync. When a Hive-authored lane PR lives on a contributor fork, is behind or dirty, and has "allow edits by maintainers" enabled, Hive may call GitHub's update-branch API. Clean BEHIND PRs get a GitHub-authored merge commit; DIRTY PRs fall back to the base-moved repair note and kick. Requires the agent mode that permits update-branch (ISSUES_PRS_MERGE).`)}
+
+
+ Merge only on current base ${yamlHint('auto_merge.require_current_base_default')} ${settingHelpMark('operator-reference', 'app-self-merge-sweep-auto_merge', 'Merge only on current base', `OFF by default. Before auto-merging in any lane, require the PR head to contain the current base tip; a green head tested on an older base is updated with GitHub update-branch and merges once CI is green on the new head. Costs one compare call per merge candidate. Per-repo overrides live on the repo card.`)} +
Post review comments ${yamlHint('review.post_comments')} ${settingHelpMark('review-swarm', 'configuration', 'Post review comments', `OFF by default. Reviewers publish their verdict as a PR comment through the hive-review relay, in addition to returning it to the merge queue. Off, the verdict stays internal, which on a hive without auto-merge means nobody reads it. Turn this on so a review reaches the human who has to decide.`)} diff --git a/src/pkg/dashboard/static-src/js/config-governor.js b/src/pkg/dashboard/static-src/js/config-governor.js index ab111e632d..a5c0ddf032 100644 --- a/src/pkg/dashboard/static-src/js/config-governor.js +++ b/src/pkg/dashboard/static-src/js/config-governor.js @@ -992,6 +992,11 @@ const rtHoldEnvLocked = !!_configState.data.reporterTrustHoldEnvLocked; const repoRtHold = _configState.data.repoReporterTrustHold || {}; const rtGateOn = !!((_configState.data.reporterTrust || {}).enabled); + // #15335 current-base merge gate: hive-wide default lives on the + // Features tab ("Merge only on current base"); each repo row carries + // the inherit / on / off override. + const cbDefault = !!_configState.data.currentBaseDefault; + const repoCurrentBase = _configState.data.repoCurrentBase || {}; // #11313 label-driven approval: per-repo opt-in plus project-wide trust. const repoLabelDriven = _configState.data.repoLabelDriven || {}; const ldApproval = _configState.data.labelDrivenApproval || {}; @@ -1062,6 +1067,16 @@ ? '' : 'inherits'; const rtRow = '' + rtInherit; + const cbPolicy = repoCurrentBase[r] || {}; + const cbHasOverride = Object.prototype.hasOwnProperty.call(cbPolicy, 'value'); + const cbEffective = cbHasOverride ? !!cbPolicy.value : (Object.prototype.hasOwnProperty.call(cbPolicy, 'effective') ? !!cbPolicy.effective : cbDefault); + const cbTitle = cbHasOverride + ? 'This repo has an explicit "merge only on current base" override (auto_merge.' + (cbPolicy.value ? 'require_current_base' : 'skip_current_base') + ').' + : 'Inherits the Features tab\'s "Merge only on current base" default (currently ' + (cbDefault ? 'on' : 'off') + ').'; + const cbInherit = cbHasOverride + ? '' + : 'inherits'; + const cbRow = '' + cbInherit; // #11313 label-driven approvals (Prow-style): opt-in per repo, with the // sub-row (approval labels + help) only while the toggle is on. const ld = repoLabelDriven[r] || {}; @@ -1073,7 +1088,7 @@
`; // Fully forge-qualified so the row is unambiguous: github.ibm.com/org/repo. const displayName = ghHost + '/' + r; - return `
${isDefault ? '★' : '☆'}${esc(displayName)}${inheritButton}${rtRow}${pillLabel}
` + ldSub; + return `
${isDefault ? '★' : '☆'}${esc(displayName)}${inheritButton}${rtRow}${cbRow}${pillLabel}
` + ldSub; }).join(''); const hostNote = isGHE ? ` on ${esc(ghHost)} (GitHub Enterprise)` @@ -1225,6 +1240,29 @@ renderConfigTab('Repos'); } + // #15335 current-base gate per-repo override (Repos tab): true writes the + // repo into auto_merge.require_current_base, false into + // auto_merge.skip_current_base, null clears it from both. + function repoCurrentBasePayload() { + return Object.fromEntries(Object.entries(_configState.data.repoCurrentBase || {}).map(([k, v]) => [k, Object.prototype.hasOwnProperty.call(v, 'value') ? v.value : null])); + } + + function toggleRepoCurrentBase(repo, checked) { + if (!_configState.data.repoCurrentBase) _configState.data.repoCurrentBase = {}; + _configState.data.repoCurrentBase[repo] = { value: !!checked, effective: !!checked }; + markDirty('repos', 'repoCurrentBase', repoCurrentBasePayload()); + renderConfigTab('Repos'); + } + + function clearRepoCurrentBaseOverride(repo) { + if (!_configState.data.repoCurrentBase) _configState.data.repoCurrentBase = {}; + _configState.data.repoCurrentBase[repo] = { effective: !!_configState.data.currentBaseDefault }; + const payload = repoCurrentBasePayload(); + payload[repo] = null; + markDirty('repos', 'repoCurrentBase', payload); + renderConfigTab('Repos'); + } + // #11313 label-driven approval controls (Repos tab). Per-repo entries are // sent whole so the server can clear or set the opt-in and its labels in // one PUT; project-wide knobs travel in their own bag. diff --git a/src/pkg/dashboard/static-src/js/repos-render.js b/src/pkg/dashboard/static-src/js/repos-render.js index ebbcad8067..c60dde40c0 100644 --- a/src/pkg/dashboard/static-src/js/repos-render.js +++ b/src/pkg/dashboard/static-src/js/repos-render.js @@ -299,6 +299,9 @@ const autoMergeLevelOK = Number((status && status.acmmLevel) || 0) >= 6; const swarming = activeSwarmRepo && activeSwarmRepo.toLowerCase() === cardRepo.toLowerCase(); const swarmPill = swarming ? `🐝 swarm` : ''; + // #15335: the effective current-base merge gate for this repo + // (Features default or the repo's own override on the Repos tab). + const currentBasePill = r.requireCurrentBase ? `current-base` : ''; const canPauseRepo = canToggleHold; // Asymmetric gate (#9070): repo-write users may switch auto-merge OFF, // but only a verified owner may switch it back ON — mirror the server. @@ -337,7 +340,7 @@ ${cardForge.kind === 'github' ? `
${esc(hostLabel)}${isPublic ? '' : ' · Enterprise'}
` : `
${cardForge.icon} ${esc(cardForge.name)} · ${esc(cardForge.host)}
`} -
${orderHandle}${esc(r.full || r.name)}${overviewFilter && overviewRepoMatches ? `${overviewRepoMatches.count} matching` : ''}${pillFilterIsActive ? repoPillFilterClearChip(repoFilterCounts) : ''}${swarmPill}${forkPill}${pausedPill}${autoMergeBtn}${writebackCtl}${swarmBtn}${pauseBtn}
+
${orderHandle}${esc(r.full || r.name)}${overviewFilter && overviewRepoMatches ? `${overviewRepoMatches.count} matching` : ''}${pillFilterIsActive ? repoPillFilterClearChip(repoFilterCounts) : ''}${swarmPill}${currentBasePill}${forkPill}${pausedPill}${autoMergeBtn}${writebackCtl}${swarmBtn}${pauseBtn}
diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 0df4731e5e..72431e7c8b 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -2678,6 +2678,7 @@ .repo-swarm-btn { flex: 0 0 auto; font-size: var(--fs-2xs); font-weight: 700; line-height: 1; padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill); white-space: nowrap; cursor: pointer; border: 1px solid color-mix(in srgb, var(--amber) 40%, var(--border)); background: color-mix(in srgb, var(--amber) 10%, transparent); color: var(--amber); opacity: 0.85; transition: opacity 0.15s, color 0.15s, border-color 0.15s; } .repo-swarm-btn:hover { opacity: 1; border-color: var(--amber); } .repo-swarm-btn[data-busy="1"] { opacity: 0.5; cursor: default; } + .repo-current-base-pill { flex: 0 0 auto; font-size: var(--fs-2xs); font-weight: 700; letter-spacing: 0.02em; line-height: 1; padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill); white-space: nowrap; border: 1px solid color-mix(in srgb, var(--green) 45%, transparent); background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); cursor: help; } .repo-swarm-pill { flex: 0 0 auto; font-size: var(--fs-2xs); font-weight: 800; letter-spacing: 0.02em; line-height: 1; padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill); white-space: nowrap; text-transform: uppercase; border: 1px solid color-mix(in srgb, var(--amber) 55%, transparent); background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); } .swarm-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(12rem, 20rem); gap: var(--sp-5); align-items: start; margin: var(--sp-0) var(--sp-0) var(--sp-5); padding: var(--sp-5); border: 1px solid var(--border); border-radius: var(--r-lg); background: color-mix(in srgb, var(--amber) 5%, var(--surface)); } .swarm-title { font-weight: 800; color: var(--amber); margin-bottom: var(--sp-2); } @@ -28277,6 +28278,9 @@

All labels

const autoMergeLevelOK = Number((status && status.acmmLevel) || 0) >= 6; const swarming = activeSwarmRepo && activeSwarmRepo.toLowerCase() === cardRepo.toLowerCase(); const swarmPill = swarming ? `🐝 swarm` : ''; + // #15335: the effective current-base merge gate for this repo + // (Features default or the repo's own override on the Repos tab). + const currentBasePill = r.requireCurrentBase ? `current-base` : ''; const canPauseRepo = canToggleHold; // Asymmetric gate (#9070): repo-write users may switch auto-merge OFF, // but only a verified owner may switch it back ON — mirror the server. @@ -28315,7 +28319,7 @@

All labels

${cardForge.kind === 'github' ? `
${esc(hostLabel)}${isPublic ? '' : ' · Enterprise'}
` : `
${cardForge.icon} ${esc(cardForge.name)} · ${esc(cardForge.host)}
`} -
${orderHandle}${esc(r.full || r.name)}${overviewFilter && overviewRepoMatches ? `${overviewRepoMatches.count} matching` : ''}${pillFilterIsActive ? repoPillFilterClearChip(repoFilterCounts) : ''}${swarmPill}${forkPill}${pausedPill}${autoMergeBtn}${writebackCtl}${swarmBtn}${pauseBtn}
+
${orderHandle}${esc(r.full || r.name)}${overviewFilter && overviewRepoMatches ? `${overviewRepoMatches.count} matching` : ''}${pillFilterIsActive ? repoPillFilterClearChip(repoFilterCounts) : ''}${swarmPill}${currentBasePill}${forkPill}${pausedPill}${autoMergeBtn}${writebackCtl}${swarmBtn}${pauseBtn}
@@ -52747,6 +52751,11 @@

Clanker-requested PRs

const rtHoldEnvLocked = !!_configState.data.reporterTrustHoldEnvLocked; const repoRtHold = _configState.data.repoReporterTrustHold || {}; const rtGateOn = !!((_configState.data.reporterTrust || {}).enabled); + // #15335 current-base merge gate: hive-wide default lives on the + // Features tab ("Merge only on current base"); each repo row carries + // the inherit / on / off override. + const cbDefault = !!_configState.data.currentBaseDefault; + const repoCurrentBase = _configState.data.repoCurrentBase || {}; // #11313 label-driven approval: per-repo opt-in plus project-wide trust. const repoLabelDriven = _configState.data.repoLabelDriven || {}; const ldApproval = _configState.data.labelDrivenApproval || {}; @@ -52817,6 +52826,16 @@

Clanker-requested PRs

? '' : 'inherits'; const rtRow = '' + rtInherit; + const cbPolicy = repoCurrentBase[r] || {}; + const cbHasOverride = Object.prototype.hasOwnProperty.call(cbPolicy, 'value'); + const cbEffective = cbHasOverride ? !!cbPolicy.value : (Object.prototype.hasOwnProperty.call(cbPolicy, 'effective') ? !!cbPolicy.effective : cbDefault); + const cbTitle = cbHasOverride + ? 'This repo has an explicit "merge only on current base" override (auto_merge.' + (cbPolicy.value ? 'require_current_base' : 'skip_current_base') + ').' + : 'Inherits the Features tab\'s "Merge only on current base" default (currently ' + (cbDefault ? 'on' : 'off') + ').'; + const cbInherit = cbHasOverride + ? '' + : 'inherits'; + const cbRow = '' + cbInherit; // #11313 label-driven approvals (Prow-style): opt-in per repo, with the // sub-row (approval labels + help) only while the toggle is on. const ld = repoLabelDriven[r] || {}; @@ -52828,7 +52847,7 @@

Clanker-requested PRs

`; // Fully forge-qualified so the row is unambiguous: github.ibm.com/org/repo. const displayName = ghHost + '/' + r; - return `
${isDefault ? '★' : '☆'}${esc(displayName)}${inheritButton}${rtRow}${pillLabel}
` + ldSub; + return `
${isDefault ? '★' : '☆'}${esc(displayName)}${inheritButton}${rtRow}${cbRow}${pillLabel}
` + ldSub; }).join(''); const hostNote = isGHE ? ` on ${esc(ghHost)} (GitHub Enterprise)` @@ -52980,6 +52999,29 @@

Clanker-requested PRs

renderConfigTab('Repos'); } + // #15335 current-base gate per-repo override (Repos tab): true writes the + // repo into auto_merge.require_current_base, false into + // auto_merge.skip_current_base, null clears it from both. + function repoCurrentBasePayload() { + return Object.fromEntries(Object.entries(_configState.data.repoCurrentBase || {}).map(([k, v]) => [k, Object.prototype.hasOwnProperty.call(v, 'value') ? v.value : null])); + } + + function toggleRepoCurrentBase(repo, checked) { + if (!_configState.data.repoCurrentBase) _configState.data.repoCurrentBase = {}; + _configState.data.repoCurrentBase[repo] = { value: !!checked, effective: !!checked }; + markDirty('repos', 'repoCurrentBase', repoCurrentBasePayload()); + renderConfigTab('Repos'); + } + + function clearRepoCurrentBaseOverride(repo) { + if (!_configState.data.repoCurrentBase) _configState.data.repoCurrentBase = {}; + _configState.data.repoCurrentBase[repo] = { effective: !!_configState.data.currentBaseDefault }; + const payload = repoCurrentBasePayload(); + payload[repo] = null; + markDirty('repos', 'repoCurrentBase', payload); + renderConfigTab('Repos'); + } + // #11313 label-driven approval controls (Repos tab). Per-repo entries are // sent whole so the server can clear or set the opt-in and its labels in // one PUT; project-wide knobs travel in their own bag. @@ -55301,6 +55343,10 @@

${esc(s.title)}

Sync lane-authored contributor fork PRs with base ${settingHelpMark('review-swarm', 'configuration', 'Sync lane-authored contributor fork PRs with base', `OFF by default. Owner gate for review.contributor_prs.base_sync. When a Hive-authored lane PR lives on a contributor fork, is behind or dirty, and has "allow edits by maintainers" enabled, Hive may call GitHub's update-branch API. Clean BEHIND PRs get a GitHub-authored merge commit; DIRTY PRs fall back to the base-moved repair note and kick. Requires the agent mode that permits update-branch (ISSUES_PRS_MERGE).`)}
+
+
+ Merge only on current base ${yamlHint('auto_merge.require_current_base_default')} ${settingHelpMark('operator-reference', 'app-self-merge-sweep-auto_merge', 'Merge only on current base', `OFF by default. Before auto-merging in any lane, require the PR head to contain the current base tip; a green head tested on an older base is updated with GitHub update-branch and merges once CI is green on the new head. Costs one compare call per merge candidate. Per-repo overrides live on the repo card.`)} +
Post review comments ${yamlHint('review.post_comments')} ${settingHelpMark('review-swarm', 'configuration', 'Post review comments', `OFF by default. Reviewers publish their verdict as a PR comment through the hive-review relay, in addition to returning it to the merge queue. Off, the verdict stays internal, which on a hive without auto-merge means nobody reads it. Turn this on so a review reaches the human who has to decide.`)} diff --git a/src/pkg/dashboard/status_builder.go b/src/pkg/dashboard/status_builder.go index ed5d91ea41..be43d6132f 100644 --- a/src/pkg/dashboard/status_builder.go +++ b/src/pkg/dashboard/status_builder.go @@ -2469,6 +2469,7 @@ func buildReposWithForge(cfg *config.Config, actionable *github.ActionableResult NonActionableIssues: nonActionableIssuesByRepo[repoName], NonActionablePrs: nonActionablePrsByRepo[repoName], AutoMerge: cfg.RepoAutoMergeEnabled(repoName), + RequireCurrentBase: cfg.AutoMerge.RequireCurrentBaseFor(full), Forge: forgeKind, ForgeURL: forgeURL, } diff --git a/src/pkg/github/automerge/automerge_current_base.go b/src/pkg/github/automerge/automerge_current_base.go index 9e2024608b..d9cdf6de63 100644 --- a/src/pkg/github/automerge/automerge_current_base.go +++ b/src/pkg/github/automerge/automerge_current_base.go @@ -110,10 +110,11 @@ func (c *Engine) currentBaseGate(ctx context.Context, displayRepo, owner, repo s c.info("automerge head is behind the current base; updating before merge", "repo", displayRepo, "pr", number, "base", baseBranch, "behind_by", cmp.GetBehindBy()) event, reason, err := c.updateBranchAndSkip(ctx, displayRepo, owner, repo, number, headSHA, currentBaseUpdateReason, fork) if currentBaseUpdateUnavailable(reason, err) && !c.requireCurrentBaseStrictFor(owner+"/"+repo) { - // Default-on gate (#15335) on a head the App may not write: parking - // it would turn every non-editable fork PR fleet-wide into a stall - // a human has to clear, so keep the pre-gate behaviour for this PR - // and say so once. Strict (explicitly listed) repos still park. + // Gate inherited from the hive-wide default (#15335) on a head the App + // may not write: parking it would turn every non-editable fork PR + // into a stall a human has to clear, so keep the pre-gate behaviour + // for this PR and say so once. Strict (explicitly listed) repos + // still park. c.warnCurrentBaseFallbackOnce(displayRepo, number, reason, err) return AutoMergeSweepEvent{}, "", false, nil } diff --git a/src/pkg/github/automerge/automerge_current_base_test.go b/src/pkg/github/automerge/automerge_current_base_test.go index 8edf2eb257..30e27de9b5 100644 --- a/src/pkg/github/automerge/automerge_current_base_test.go +++ b/src/pkg/github/automerge/automerge_current_base_test.go @@ -87,7 +87,7 @@ func TestCurrentBaseGate(t *testing.T) { } } -// TestCurrentBaseGateUpdateUnavailableFallback pins the default-on guard +// TestCurrentBaseGateUpdateUnavailableFallback pins the inherited-default guard // (hivecommons/hive#15335): when the App cannot update a behind head — a fork // without maintainer edits, or a same-repo 403 from branch protection — a // repo gated only by the default merges the head as tested and WARNs once diff --git a/src/pkg/github/automerge/automerge_sweep.go b/src/pkg/github/automerge/automerge_sweep.go index 29adabaf61..3c78307572 100644 --- a/src/pkg/github/automerge/automerge_sweep.go +++ b/src/pkg/github/automerge/automerge_sweep.go @@ -92,7 +92,8 @@ type Options struct { // nil means no repo has any. HumanMergePaths func(repo string) []string // RequireCurrentBase returns the live current-base gate switch for an - // owner/repo (hivecommons/hive#13634, default on since #15335 via + // owner/repo (hivecommons/hive#13634; since #15335 resolved from the + // hive-wide default plus per-repo overrides via // config.AutoMergeConfig.RequireCurrentBaseFor). nil means off. RequireCurrentBase func(repo string) bool // RequireCurrentBaseStrict reports whether owner/repo is explicitly