From ff60153d8a287e76da7b1ed8fac344cad8f9e2e8 Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 01:08:16 +0000 Subject: [PATCH 01/13] =?UTF-8?q?=F0=9F=90=9B=20fix:=20label=20narrow=20da?= =?UTF-8?q?shboard=20navigation=20(#16678)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 fix: label narrow dashboard navigation Make the drawer entry point recognizable when the sidebar is hidden, and keep its accessible name in sync with the drawer state. Hive-Run: hivecommons/hive#16654 Hive-Plan: dashboard-narrow-navigation Hive-Spec: issue-16654#navigation-access Co-authored-by: MikeSpreitzer <14296719+MikeSpreitzer@users.noreply.github.com> Signed-off-by: Karibhou * fix: apply responsive navigation chip classes Signed-off-by: Karibhou --------- Signed-off-by: Karibhou Co-authored-by: Karibhou Co-authored-by: MikeSpreitzer <14296719+MikeSpreitzer@users.noreply.github.com> Co-authored-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-16654-navigation-label.md | 1 + src/pkg/dashboard/static-src/html/topbar.html | 4 ++-- src/pkg/dashboard/static-src/js/chat.js | 3 ++- src/pkg/dashboard/static/index.html | 7 ++++--- 4 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 changelog.d/fixed-16654-navigation-label.md diff --git a/changelog.d/fixed-16654-navigation-label.md b/changelog.d/fixed-16654-navigation-label.md new file mode 100644 index 0000000000..d32f536cd1 --- /dev/null +++ b/changelog.d/fixed-16654-navigation-label.md @@ -0,0 +1 @@ +- Label the narrow dashboard's navigation drawer button so operators can find sidebar sections and version details without guessing what the menu icon does (#16654). diff --git a/src/pkg/dashboard/static-src/html/topbar.html b/src/pkg/dashboard/static-src/html/topbar.html index 4b943b428e..4ceaff3d88 100644 --- a/src/pkg/dashboard/static-src/html/topbar.html +++ b/src/pkg/dashboard/static-src/html/topbar.html @@ -1,9 +1,9 @@
- + title="Open navigation">Navigation
diff --git a/src/pkg/dashboard/static-src/js/chat.js b/src/pkg/dashboard/static-src/js/chat.js index 04a20dd0b7..2f94867431 100644 --- a/src/pkg/dashboard/static-src/js/chat.js +++ b/src/pkg/dashboard/static-src/js/chat.js @@ -531,7 +531,8 @@ sidebar.classList.toggle('open', open); backdrop.classList.toggle('open', open); toggle.setAttribute('aria-expanded', open ? 'true' : 'false'); - toggle.setAttribute('aria-label', open ? 'Close menu' : 'Open menu'); + toggle.setAttribute('aria-label', open ? 'Close navigation' : 'Open navigation'); + toggle.title = open ? 'Close navigation' : 'Open navigation'; } function closeDrawer() { if (isOpen()) setOpen(false); } diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 0c8a192069..7a179d8f2b 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -7964,9 +7964,9 @@

🐝 Getting Started
- + title="Open navigation">Navigation
@@ -66797,7 +66797,8 @@

${model.editIndex === null ? 'Add Event trigger' : 'Edit Event trigger'}

Date: Wed, 4 Nov 2026 20:20:41 -0500 Subject: [PATCH 02/13] =?UTF-8?q?=F0=9F=93=96=20docs:=20app=5Fsigned=5Fcom?= =?UTF-8?q?mits=20is=20a=20Settings=20toggle;=20add=20operator-reference?= =?UTF-8?q?=20row=20(#16684)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit running-at-level-6.md G8 called github.app_signed_commits YAML-only, but the dashboard has had the switch under Settings → Forge App since the toggle landed, and operator-reference/README.md had no row for the key at all. Add the row (default off, App-only, what it rewrites, fallbacks, Settings location, link to github-app-setup.md) and name the dashboard location in github-app-setup.md next to the YAML snippet. Signed-off-by: Andrew Anderson Co-authored-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/changed-app-signed-commits-docs.md | 1 + src/docs/github-app-setup.md | 2 ++ src/docs/operator-reference/README.md | 1 + src/docs/running-at-level-6.md | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelog.d/changed-app-signed-commits-docs.md diff --git a/changelog.d/changed-app-signed-commits-docs.md b/changelog.d/changed-app-signed-commits-docs.md new file mode 100644 index 0000000000..abc5a7a904 --- /dev/null +++ b/changelog.d/changed-app-signed-commits-docs.md @@ -0,0 +1 @@ +- Docs: `github.app_signed_commits` now has an operator-reference row (default off, App-only, what it rewrites, fallbacks, Settings location) and the level-6 checklist and `github-app-setup.md` point at its dashboard switch (Settings → Forge App → "Re-author agent PRs as GitHub-signed commits") instead of calling it YAML-only. diff --git a/src/docs/github-app-setup.md b/src/docs/github-app-setup.md index 81db0abb0c..32fc466ff8 100644 --- a/src/docs/github-app-setup.md +++ b/src/docs/github-app-setup.md @@ -209,6 +209,8 @@ github: app_signed_commits: true # opt-in; needs an installed App ``` +In the dashboard the same switch is **Settings → Forge App → Re-author agent PRs as GitHub-signed commits** (Owner role required to save). + With it on, the PR-request watcher (the choke point every `hive-open-pr` request passes through) re-authors the head branch before it opens the PR: it reads the `base...head` diff, builds one commit through the mutation with the App installation token — same tree, the agents' original commit messages and DCO trailers as the message — force-updates the branch to it, and then opens the PR. The PR arrives with a single commit, signed by GitHub, authored by `[bot]`, that a `required_signatures` rule accepts. **DCO.** The mutation takes no author: GitHub stamps its own bot account on the commit (`[bot] `). That is fine for the DCO checks - probot-dco exempts a commit whose GitHub author resolves to a Bot account, and Prow's `dco` plugin only requires a `Signed-off-by` line to be present. The `Signed-off-by` trailers copied from the agents' commits are what the hive controls, and they are re-addressed to the bracket-free form the pane identity uses since #6276: a `[bot]@users.noreply.github.com` sign-off (with or without GitHub's numeric prefix) becomes `@hive.kubestellar.io` (`HIVE_GIT_BOT_EMAIL_DOMAIN`), because probot-dco rejects the bracketed local-part as "not a valid email address" wherever it does validate it (#6251). Every other sign-off address, a human's or the legacy `hive-bot@kubestellar.io`, is copied unchanged. diff --git a/src/docs/operator-reference/README.md b/src/docs/operator-reference/README.md index 2757cd42a3..cd7e9ed183 100644 --- a/src/docs/operator-reference/README.md +++ b/src/docs/operator-reference/README.md @@ -241,6 +241,7 @@ Go callers keep reading `cfg.Agents`, `cfg.Governor.Gateways` and so on through | `github.pr_detail_ttl_s` | `1800` seconds. `HIVE_GITHUB_PR_DETAIL_TTL` overrides for tests/experiments. | Reuses `GET /pulls/{number}` detail responses while the cheap PR list still reports the same `head.sha` and `updated_at`, and GitHub has resolved `mergeable_state`. | | `github.graphql_pr_batch` | `true` | Uses one paginated GraphQL query per repository scan to populate the PR detail cache and CI rollup cache, replacing most per-PR `GET /pulls/{number}` and `check-runs` reads. Set `false` to return to the REST-only scan path. | | `github.graphql_pr_batch_page_size` | `50` | Page size for the GraphQL `pullRequests(first:)` batch. Values above GitHub's `100` maximum are rejected. | +| `github.app_signed_commits` | Unset (off). App-authenticated hives only; PAT-authenticated hives ignore it. Settings → Forge App → **Re-author agent PRs as GitHub-signed commits** (Owner role). | Opt-in for repositories whose ruleset requires signed commits (`required_signatures`). Agents commit with plain `git` in their pane and cannot sign, so without it every agent PR is unmergeable there however many approvals it has. With it on, the PR-request watcher re-authors the head branch before the PR opens as one commit created through the GraphQL `createCommitOnBranch` mutation with the App installation token — same tree, the agents' messages and DCO trailers as the message — which GitHub signs and shows as **Verified**, authored by `[bot]`. A reconcile pass (at most once a minute) re-signs the hive's own unsigned follow-up pushes on open App-authored PRs the same way. Falls back to the plain unsigned push (PR still opens; `signed_skipped` in the request's `.result.json` and a WARN in the hive log) for changes the mutation cannot express (executable bits, symlinks, submodule pointers), more than 20 MiB of content or 300 files, a head that moved mid-rewrite, or a head that already has an open PR. A person's commit or a merge commit in the range stops the reconcile with one `hive:signed-commits-blocked` comment. See [github-app-setup.md](../github-app-setup.md#signed-commits-on-agent-prs-app_signed_commits). | | `governor.logging.kick_log_source` | `scrollback`. Also `transcript` or `auto`; unknown values mean `scrollback`. `HIVE_KICK_LOG_SOURCE` (when set to a valid value) wins over this key. | What per-kick logs (archives and the live full log) are built from: the tmux scrollback, the backend CLI's own transcript (Copilot CLI, Claude Code), or the transcript when a reader exists else the scrollback. Editable under **Settings → Logging → Kick log source**; applies to the next kick without a restart, and each log's header `source:` line (and the kick history page) shows which was used. See [agent-logging.md](../agent-logging.md#per-kick-log-history). | | `governor.labels.automerge` | Defaults to `lgtm`. | Label applied when a merger/owner queues a PR for Hive auto-merge-on-green. With Prow's commit binding (prow-github-actions v3), Hive binds `lgtm` by also setting the `prow/lgtm` commit status (needs the App's `statuses: write` permission); alternatively choose a distinct label such as `hive/auto-merge`. Distinct from the [App self-merge sweep](#app-self-merge-sweep-auto_merge), which needs no label and no human queuer. | | `project.repo_policies[].auto_merge` | effective `false` below L6; unset = `true` at L6 | Per-repo off switch. Switching to L6 turns this on for every active repo; owners can toggle repos afterward. `false` lets Hive open PRs for that repo but blocks all Hive merge paths (`hive-merge`, App self-authored sweep, and proxy-visible direct REST/GraphQL merge attempts). The dashboard repo-card switch persists this key and takes effect without restart. | diff --git a/src/docs/running-at-level-6.md b/src/docs/running-at-level-6.md index 4ceee9d077..bbab0bb8f2 100644 --- a/src/docs/running-at-level-6.md +++ b/src/docs/running-at-level-6.md @@ -165,7 +165,7 @@ For hosted and self-hosted hives alike, GitHub repository/organization administr | **G5. Require an up-to-date base.** Enable strict required checks/"Require branches to be up to date before merging" on each protected branch. | Green on an older base does not establish green after integration. Verify a PR becomes blocked after a base push until updated/retested. The sweep attempts updates for `behind`; see [sweep](../pkg/github/automerge/automerge_sweep.go). | | **G6. Allow the merge methods actually used.** Settings → General → Pull Requests: allow squash; also allow merge commits if managing release-line forward merges. | The ordinary method is squash; recognized forward merges use merge commits to preserve ancestry. Disallowed methods cause merge refusals. Verify landing method in a test PR and ancestry for a sync PR. See `mergeMethodFor` in [sweep](../pkg/github/automerge/automerge_sweep.go) and [pull requests](../pkg/github/pullrequest.go). | | **G7. Keep fork-run approval deliberate.** Settings → Actions → General → Approval for running fork pull request workflows: choose the trust policy your maintainers can service. **JUDGMENT CALL:** require approval for untrusted fork authors rather than relaxing it to drain a queue. | Unapproved runs are `action_required`, not successful CI. Have a maintainer inspect the workflow/diff then approve runs; verify check evidence appears at the PR head. See `forkRunApprovalReason` in [CI gate](../pkg/github/merge_ci_gate.go). | -| **G8. Test signed-commit requirements end to end.** If your ruleset requires signatures, enable `github.app_signed_commits` in Hive runtime YAML (not a dashboard switch) and test follow-up commits too. | An unsigned follow-up can strand an otherwise green PR. Hive reconciles its own commits, not people's work. Verify GitHub's Verified badge at the latest head and branch-rule acceptance. See [signed reconciliation](../pkg/github/pr_signed_reconcile.go). | +| **G8. Test signed-commit requirements end to end.** If your ruleset requires signatures, enable `github.app_signed_commits` (Settings → Forge App → **Re-author agent PRs as GitHub-signed commits**, Owner role; or in Hive runtime YAML) and test follow-up commits too. | An unsigned follow-up can strand an otherwise green PR. Hive reconciles its own commits, not people's work. Verify GitHub's Verified badge at the latest head and branch-rule acceptance. See [signed reconciliation](../pkg/github/pr_signed_reconcile.go). | ### Test coverage of 90% or better From 4e7e4048d755a7ba7599d6f5d4aaba606645d112 Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 02:24:21 +0000 Subject: [PATCH 03/13] fix(automerge): only re-sign the hive's own commits in in-place DCO repair (#16698) #16648 let a hive-authored PR on a pushable base-repo head be amended in place whatever its unsigned commits were linked to, because commits the hive's agents push as project.ai_author counted as "other" (only App-bot linkage made a commit the hive's). As a result a collaborator with push access who added an unsigned commit to a hive branch got a Signed-off-by asserted for them by the App. The hive/other split now also counts commits GitHub links (by author login) to one of the hive's identities (StageLabelPolicy.HiveAuthor), so #16648's case still amends in place, and in-place repair again requires every unsigned commit to be the hive's. A hive-authored PR carrying anyone else's unsigned commit waits for a person; it is still never superseded. Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- changelog.d/fixed-16685.md | 1 + .../automerge/automerge_contributor_adopt.go | 17 +++++++---- .../automerge_contributor_adopt_test.go | 18 +++++++++--- .../github/automerge/automerge_stage_dco.go | 28 +++++++++++++++++-- .../automerge/automerge_stage_labels_test.go | 23 +++++++++++++++ 5 files changed, 75 insertions(+), 12 deletions(-) create mode 100644 changelog.d/fixed-16685.md diff --git a/changelog.d/fixed-16685.md b/changelog.d/fixed-16685.md new file mode 100644 index 0000000000..d7752470be --- /dev/null +++ b/changelog.d/fixed-16685.md @@ -0,0 +1 @@ +- In-place DCO repair no longer appends the App's Signed-off-by to a collaborator's unsigned commit on a hive-authored PR: only commits GitHub links to the App bot or a hive identity are re-signed, and a hive-authored PR carrying anyone else's unsigned commit waits for a person instead ([#16685](https://github.com/hivecommons/hive/issues/16685)). diff --git a/src/pkg/github/automerge/automerge_contributor_adopt.go b/src/pkg/github/automerge/automerge_contributor_adopt.go index 4e7c9bd876..4840918aa2 100644 --- a/src/pkg/github/automerge/automerge_contributor_adopt.go +++ b/src/pkg/github/automerge/automerge_contributor_adopt.go @@ -299,16 +299,21 @@ func adoptionNeedsDCORehome(obs stageObservation, canPushInPlace, hiveAuthored b // the App's REST token, so a fork head re-homes (AdoptModeSupersede) even // when every unsigned commit is the hive's (hivecommons/hive#14666). // -// A hive-authored PR (hiveAuthored: the App bot or project.ai_author opened -// it) is never re-homed: every commit on it is the hive's to sign, so a -// pushable base-repo head is amended in place and any other head keeps its -// PR number, approvals and CI history and waits for a person (""), -// rather than restarting as a copy (hivecommons/hive#16619). +// Only the hive's own unsigned commits are ever signed in place: those GitHub +// links to the App bot or to one of the hive's identities +// (project.ai_author). A hive-authored PR (hiveAuthored: the App bot or +// project.ai_author opened it) is never re-homed: a pushable base-repo head +// whose unsigned commits are all the hive's is amended in place, and any +// other head — including one carrying a collaborator's unsigned commit, +// which the App must not sign for them (hivecommons/hive#16685) — keeps its +// PR number, approvals and CI history and waits for a person (""), rather +// than restarting as a copy (hivecommons/hive#16619). func adoptionDCORepairMode(obs stageObservation, canPushInPlace, hiveAuthored bool) string { if obs.Detail.DCO != stagelabels.DCONo || obs.Detail.DCOUnsigned <= 0 { return "" } - if canPushInPlace && headInBaseRepo(obs) && (hiveAuthored || (obs.Detail.DCOUnsignedHive == obs.Detail.DCOUnsigned && obs.Detail.DCOUnsignedOther == 0)) { + allHive := obs.Detail.DCOUnsignedOther == 0 && (hiveAuthored || obs.Detail.DCOUnsignedHive == obs.Detail.DCOUnsigned) + if canPushInPlace && headInBaseRepo(obs) && allHive { return stagelabels.AdoptModeInPlace } if hiveAuthored { diff --git a/src/pkg/github/automerge/automerge_contributor_adopt_test.go b/src/pkg/github/automerge/automerge_contributor_adopt_test.go index 37a5043e98..ccaa9b655a 100644 --- a/src/pkg/github/automerge/automerge_contributor_adopt_test.go +++ b/src/pkg/github/automerge/automerge_contributor_adopt_test.go @@ -626,14 +626,24 @@ func TestAdoptionDCORehomeDecisionAndRendering(t *testing.T) { t.Fatal("signed head does not need DCO re-home") } // A hive-authored PR (hivecommons/hive#16619) is never re-homed for - // sign-off: a pushable base-repo head is amended in place whoever the - // unsigned commits are linked to; a fork head keeps its PR and waits. + // sign-off: a pushable base-repo head whose unsigned commits are all + // the hive's is amended in place; one carrying someone else's unsigned + // commit is not signed by the App and waits (hivecommons/hive#16685); + // a fork head keeps its PR and waits. own := obs - own.Author, own.Detail.DCOUnsigned, own.Detail.DCOUnsignedOther = "thatguywob", 2, 2 + own.Author, own.Detail.DCOUnsigned, own.Detail.DCOUnsignedHive, own.Detail.DCOUnsignedOther = "thatguywob", 2, 2, 0 own.Owner, own.Repo, own.HeadRepo = "acme", "widget", "acme/widget" if got := adoptionDCORepairMode(own, true, true); got != stagelabels.AdoptModeInPlace { - t.Fatalf("hive-authored base-repo head: mode=%q, want in-place amend", got) + t.Fatalf("hive-authored base-repo head, all unsigned commits the hive's: mode=%q, want in-place amend", got) } + own.Detail.DCOUnsignedHive, own.Detail.DCOUnsignedOther = 1, 1 + if got := adoptionDCORepairMode(own, true, true); got != "" { + t.Fatalf("hive-authored base-repo head with a collaborator's unsigned commit: mode=%q, want wait for a person", got) + } + if adoptionNeedsDCORehome(own, true, true) || adoptedHeadNeedsDCORepair(own, inPlace, true, true) || adoptedHeadNeedsDCORehome(own, inPlace, true, true) { + t.Fatal("a collaborator's unsigned commit on a hive-authored PR must be neither signed by the App nor superseded") + } + own.Detail.DCOUnsignedHive, own.Detail.DCOUnsignedOther = 0, 2 own.HeadRepo = "thatguywob/widget" if got := adoptionDCORepairMode(own, false, true); got != "" { t.Fatalf("hive-authored fork head: mode=%q, want no re-home", got) diff --git a/src/pkg/github/automerge/automerge_stage_dco.go b/src/pkg/github/automerge/automerge_stage_dco.go index ec17c37b1b..d21d02a38f 100644 --- a/src/pkg/github/automerge/automerge_stage_dco.go +++ b/src/pkg/github/automerge/automerge_stage_dco.go @@ -62,6 +62,13 @@ func dcoCommitStatsDetailedForAuthor(commits []*gh.RepositoryCommit, appLogin, p // the App bot), so no signed hive commit is squash-unsafe. Unsigned commits // are still counted and rejected. func dcoCommitStatsForSquashAuthor(commits []*gh.RepositoryCommit, appLogin, prAuthor string, selfSquash bool) dcoStats { + return dcoCommitStatsForHive(commits, appLogin, prAuthor, selfSquash, nil) +} + +// dcoCommitStatsForHive is dcoCommitStatsForSquashAuthor with the hive's own +// identities (isHive, StageLabelPolicy.HiveAuthor) counted as the hive's when +// splitting unsigned commits; a nil isHive counts only the App bot. +func dcoCommitStatsForHive(commits []*gh.RepositoryCommit, appLogin, prAuthor string, selfSquash bool, isHive func(login string) bool) dcoStats { var stats dcoStats for _, rc := range commits { if rc == nil || len(rc.Parents) > 1 { @@ -71,7 +78,7 @@ func dcoCommitStatsForSquashAuthor(commits []*gh.RepositoryCommit, appLogin, prA msg := rc.GetCommit().GetMessage() if !signedOffByRE.MatchString(msg) { stats.unsigned++ - if dcoCommitByHive(rc, appLogin) { + if dcoCommitOwnedByHive(rc, appLogin, isHive) { stats.unsignedHive++ } else { stats.unsignedOther++ @@ -92,6 +99,23 @@ func dcoCommitByHive(commit *gh.RepositoryCommit, appLogin string) bool { return commitByApp(commit, appLogin) } +// dcoCommitOwnedByHive is dcoCommitByHive that also counts a commit GitHub +// links (by author login) to one of the hive's own identities (isHive: +// project.ai_author, the login the hive's agents push as). Only GitHub's +// linkage counts here too: git author names and emails never do, so a +// collaborator's unsigned commit stays "other" and is never signed by the +// App (hivecommons/hive#16685). +func dcoCommitOwnedByHive(commit *gh.RepositoryCommit, appLogin string, isHive func(login string) bool) bool { + if dcoCommitByHive(commit, appLogin) { + return true + } + if commit == nil || isHive == nil { + return false + } + login := strings.TrimSpace(commit.GetAuthor().GetLogin()) + return login != "" && isHive(login) +} + // stageDCO returns the commit check for the observation's head, reading the // commits only when the store has no result for this head (the caller // caches the result, including how many unsigned commits are the App's own, @@ -123,7 +147,7 @@ func (c *Engine) stageDCO(ctx context.Context, store *stagelabels.Store, key str if err != nil { return dcoStats{}, err } - return dcoCommitStatsForSquashAuthor(all, appLogin, obs.Author, selfSquash), nil + return dcoCommitStatsForHive(all, appLogin, obs.Author, selfSquash, policy.HiveAuthor), nil } // hiveAuthoredPR reports whether the PR is the hive's own: author/hive by diff --git a/src/pkg/github/automerge/automerge_stage_labels_test.go b/src/pkg/github/automerge/automerge_stage_labels_test.go index 6298db61de..1bc51529a3 100644 --- a/src/pkg/github/automerge/automerge_stage_labels_test.go +++ b/src/pkg/github/automerge/automerge_stage_labels_test.go @@ -2414,6 +2414,29 @@ func TestDCOCommitStatsSkipsMerges(t *testing.T) { } } +// hivecommons/hive#16685: an unsigned commit GitHub links to one of the +// hive's identities (project.ai_author) is the hive's to sign; a +// collaborator's unsigned commit is not, whatever its git author name says. +func TestDCOCommitStatsForHiveCountsHiveIdentities(t *testing.T) { + commits := []*gh.RepositoryCommit{ + {Author: &gh.User{Login: gh.Ptr("thatguywob")}, Commit: &gh.Commit{Message: gh.Ptr("hive fix")}, Parents: []*gh.Commit{{}}}, + {Author: &gh.User{Login: gh.Ptr("collaborator")}, Commit: &gh.Commit{Message: gh.Ptr("drive-by"), Author: &gh.CommitAuthor{Name: gh.Ptr("thatguywob")}}, Parents: []*gh.Commit{{}}}, + {Author: &gh.User{Login: gh.Ptr(testHiveAppBotLogin)}, Commit: &gh.Commit{Message: gh.Ptr("app fix")}, Parents: []*gh.Commit{{}}}, + } + isHive := func(login string) bool { return strings.EqualFold(login, "thatguywob") } + stats := dcoCommitStatsForHive(commits, testHiveAppBotLogin, "thatguywob", true, isHive) + if stats.unsigned != 3 || stats.unsignedHive != 2 || stats.unsignedOther != 1 { + t.Fatalf("with hive identities: %+v, want unsigned=3 hive=2 other=1", stats) + } + stats = dcoCommitStatsForHive(commits, testHiveAppBotLogin, "thatguywob", true, nil) + if stats.unsigned != 3 || stats.unsignedHive != 1 || stats.unsignedOther != 2 { + t.Fatalf("nil predicate: %+v, want unsigned=3 hive=1 other=2", stats) + } + if old := dcoCommitStatsForSquashAuthor(commits, testHiveAppBotLogin, "thatguywob", true); old != stats { + t.Fatalf("dcoCommitStatsForSquashAuthor=%+v, want App-only split %+v", old, stats) + } +} + // hivecommons/hive#12557: a gate flapping between merge-queue and a pending // stage on one unchanged head used to post a stage-regressed comment every // sweep, because each recover re-armed the dedupe. One comment per head. From e3f54c2d120f432aceb831ccd0cd3b5fb1d22a52 Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 02:56:37 +0000 Subject: [PATCH 04/13] fix(automerge): apply one hive-ownership rule across DCO split and squash-unsafe checks (#16706) Count project.ai_author-linked commits as the hive's in the squash-unsafe check too (#16703), re-read DCO splits cached before hive identities counted (#16701), and document the email-derived login-linkage trust assumption for in-place re-signing (#16702). Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .../fixed-dco-hive-ownership-consistency.md | 1 + .../stage-labels.md | 20 +++++-- .../github/automerge/automerge_stage_dco.go | 29 ++++++--- .../automerge/automerge_stage_labels_test.go | 59 +++++++++++++++++++ src/pkg/stagelabels/stagelabels_test.go | 12 ++++ src/pkg/stagelabels/store.go | 11 +++- 6 files changed, 116 insertions(+), 16 deletions(-) create mode 100644 changelog.d/fixed-dco-hive-ownership-consistency.md diff --git a/changelog.d/fixed-dco-hive-ownership-consistency.md b/changelog.d/fixed-dco-hive-ownership-consistency.md new file mode 100644 index 0000000000..104339ea77 --- /dev/null +++ b/changelog.d/fixed-dco-hive-ownership-consistency.md @@ -0,0 +1 @@ +- DCO checks now treat commits linked to `project.ai_author` as the hive's in both the unsigned split and the squash-unsafe count, and a split cached before hive identities counted is read again once, so an in-flight hive-authored PR is re-signed instead of waiting for a person ([#16701](https://github.com/hivecommons/hive/issues/16701), [#16703](https://github.com/hivecommons/hive/issues/16703)). The docs now state that this login linkage comes from the commit email and is trusted only because the in-place path needs base-repo push access ([#16702](https://github.com/hivecommons/hive/issues/16702)). diff --git a/src/docs/labels-and-control-signals/stage-labels.md b/src/docs/labels-and-control-signals/stage-labels.md index 903ec7cd75..d722629aa0 100644 --- a/src/docs/labels-and-control-signals/stage-labels.md +++ b/src/docs/labels-and-control-signals/stage-labels.md @@ -1166,12 +1166,20 @@ When a contributor-agent PR goes red the hive does not just relabel it (a human- If an adopted head is DCO-red, an empty signed commit is never enough. "Hive-authored" is decided the same way as head attribution above: an unsigned commit is the hive's own only when GitHub links its author or - committer to the App bot; git author/committer names and emails — even a - lane-looking `@` address — are - contributor-controlled and never count. The stage pass caches that split - with the commit check (`dco_unsigned_hive`), so the decision does not - depend on which labels the PR currently carries. When every unsigned - commit is App-linked and the head lives in the **base repo**, an in-place + committer to the App bot, or its author to one of the hive's identities + (`project.ai_author`); git author/committer names — even a lane-looking + `@` address — never count on their own. + GitHub derives that login linkage from the commit email and agents push + unsigned commits, so it is not proof of origin: anyone who can push to a + base-repo branch can author a commit as `project.ai_author` and have it + re-signed. Only collaborators with push access reach the in-place path, + so the hive trusts them not to do that + ([#16702](https://github.com/hivecommons/hive/issues/16702)). The stage + pass caches that split with the commit check (`dco_unsigned_hive`), so + the decision does not depend on which labels the PR currently carries; a + split cached before hive identities counted is read again once + (`dco_split_hive_identity`). When every unsigned commit is the hive's + and the head lives in the **base repo**, an in-place adoption stays in place and the stage engine itself re-signs the branch once per head (`reason=dco-rehomed`): it replays the PR's commits through the git-data API, keeping each author, message, tree and parents (merge diff --git a/src/pkg/github/automerge/automerge_stage_dco.go b/src/pkg/github/automerge/automerge_stage_dco.go index d21d02a38f..5237934be7 100644 --- a/src/pkg/github/automerge/automerge_stage_dco.go +++ b/src/pkg/github/automerge/automerge_stage_dco.go @@ -66,8 +66,9 @@ func dcoCommitStatsForSquashAuthor(commits []*gh.RepositoryCommit, appLogin, prA } // dcoCommitStatsForHive is dcoCommitStatsForSquashAuthor with the hive's own -// identities (isHive, StageLabelPolicy.HiveAuthor) counted as the hive's when -// splitting unsigned commits; a nil isHive counts only the App bot. +// identities (isHive, StageLabelPolicy.HiveAuthor) counted as the hive's, both +// when splitting unsigned commits and when counting squash-unsafe signed ones +// (hivecommons/hive#16703); a nil isHive counts only the App bot. func dcoCommitStatsForHive(commits []*gh.RepositoryCommit, appLogin, prAuthor string, selfSquash bool, isHive func(login string) bool) dcoStats { var stats dcoStats for _, rc := range commits { @@ -83,7 +84,7 @@ func dcoCommitStatsForHive(commits []*gh.RepositoryCommit, appLogin, prAuthor st } else { stats.unsignedOther++ } - } else if !selfSquash && dcoCommitByHive(rc, appLogin) && !messageHasPRAuthorSignoff(msg, prAuthor) { + } else if !selfSquash && dcoCommitOwnedByHive(rc, appLogin, isHive) && !messageHasPRAuthorSignoff(msg, prAuthor) { stats.squashUnsafeHive++ } } @@ -102,9 +103,20 @@ func dcoCommitByHive(commit *gh.RepositoryCommit, appLogin string) bool { // dcoCommitOwnedByHive is dcoCommitByHive that also counts a commit GitHub // links (by author login) to one of the hive's own identities (isHive: // project.ai_author, the login the hive's agents push as). Only GitHub's -// linkage counts here too: git author names and emails never do, so a -// collaborator's unsigned commit stays "other" and is never signed by the -// App (hivecommons/hive#16685). +// linkage counts here too, never the git author name, so a collaborator's +// unsigned commit under their own email stays "other" and is never signed by +// the App (hivecommons/hive#16685). +// +// Trust assumption (hivecommons/hive#16702): GitHub derives the login from +// the git author email and the hive's agents push plain, unsigned git +// commits (app_signed_commits re-authors only the PR's opening head), so +// neither Commit.Verification nor the committer can tell an agent's commit +// from one a pusher authored with project.ai_author's email. Requiring +// either would stop the hive re-signing its own fix commits. The in-place +// path that acts on this split needs a base-repo head the App can push +// (adoptionDCORepairMode), so only collaborators with push access can +// present such a commit, and they are trusted not to. commitByApp has the +// same property for the App bot login. func dcoCommitOwnedByHive(commit *gh.RepositoryCommit, appLogin string, isHive func(login string) bool) bool { if dcoCommitByHive(commit, appLogin) { return true @@ -128,7 +140,10 @@ func (c *Engine) stageDCO(ctx context.Context, store *stagelabels.Store, key str } appLogin := c.transport.AppBotLogin() selfSquash := botSquashAuthor(obs.Author) || hiveAuthoredPR(obs, policy, appLogin) - if rec, ok := store.Get(key); ok { + // A split cached before hive identities counted (hivecommons/hive#16701) filed + // project.ai_author commits as "other"; read the commits once more so + // a hive-authored head is re-signed rather than left waiting. + if rec, ok := store.Get(key); ok && (policy.HiveAuthor == nil || rec.DCOSplitHiveIdentity) { if t, u, cached := rec.DCOFor(obs.HeadSHA); cached { // Records cached before the ownership split existed carry // none; an in-place adoption decides repair-vs-rehome on it, diff --git a/src/pkg/github/automerge/automerge_stage_labels_test.go b/src/pkg/github/automerge/automerge_stage_labels_test.go index 1bc51529a3..e8059712d8 100644 --- a/src/pkg/github/automerge/automerge_stage_labels_test.go +++ b/src/pkg/github/automerge/automerge_stage_labels_test.go @@ -8,6 +8,7 @@ import ( "log/slog" "net/http" "net/http/httptest" + "os" "path/filepath" "reflect" "slices" @@ -2437,6 +2438,64 @@ func TestDCOCommitStatsForHiveCountsHiveIdentities(t *testing.T) { } } +// hivecommons/hive#16703: the squash-unsafe count uses the same ownership +// rule as the unsigned split, so a signed commit GitHub links to a hive +// identity is the hive's to misattribute on a PR a squash would credit to +// someone else. +func TestDCOCommitStatsForHiveSquashUnsafeCountsHiveIdentities(t *testing.T) { + commits := []*gh.RepositoryCommit{ + {Author: &gh.User{Login: gh.Ptr("thatguywob")}, Commit: &gh.Commit{Message: gh.Ptr("hive fix\n\nSigned-off-by: Hive ")}, Parents: []*gh.Commit{{}}}, + {Author: &gh.User{Login: gh.Ptr("collaborator")}, Commit: &gh.Commit{Message: gh.Ptr("drive-by\n\nSigned-off-by: C ")}, Parents: []*gh.Commit{{}}}, + } + isHive := func(login string) bool { return strings.EqualFold(login, "thatguywob") } + if stats := dcoCommitStatsForHive(commits, testHiveAppBotLogin, "person", false, isHive); stats.unsigned != 0 || stats.squashUnsafeHive != 1 { + t.Fatalf("with hive identities: %+v, want squashUnsafeHive=1", stats) + } + if stats := dcoCommitStatsForHive(commits, testHiveAppBotLogin, "person", true, isHive); stats.squashUnsafeHive != 0 { + t.Fatalf("self squash: %+v, want squashUnsafeHive=0", stats) + } + if stats := dcoCommitStatsForHive(commits, testHiveAppBotLogin, "person", false, nil); stats.squashUnsafeHive != 0 { + t.Fatalf("nil predicate: %+v, want App-only squashUnsafeHive=0", stats) + } +} + +// hivecommons/hive#16701: a split cached before hive identities counted filed +// a project.ai_author commit as "other"; stageDCO reads that head's commits +// once more so the hive's own commit can be re-signed, then trusts the +// refreshed cache. +func TestStageDCORereadsSplitCachedBeforeHiveIdentities(t *testing.T) { + api := &stageAPI{labels: map[string]string{}, commitDetails: map[int][]stageCommitFixture{ + 42: {{message: "hive fix", authorLogin: "thatguywob"}}, + }} + srv := newStageAPI(t, api) + defer srv.Close() + e, _, _ := newStageEngine(t, srv.URL, &contributorLaneClock{at: time.Now()}) + key := stageKey("acme", "widget", 42) + path := filepath.Join(t.TempDir(), "legacy.json") + data, err := json.Marshal(map[string]stagelabels.Record{key: {DCOHead: "aaa", DCOTotal: 1, DCOUnsigned: 1, DCOUnsignedOther: 1, DCOSquashUnsafeKnown: true}}) + if err != nil { + t.Fatal(err) + } + if err := os.WriteFile(path, data, 0o644); err != nil { + t.Fatal(err) + } + store := stagelabels.NewStore(path, nil) + if err := store.Load(); err != nil { + t.Fatal(err) + } + policy := StageLabelPolicy{HiveAuthor: func(login string) bool { return strings.EqualFold(login, "thatguywob") }} + obs := stageObservation{Owner: "acme", Repo: "widget", Number: 42, HeadSHA: "aaa", Author: "thatguywob"} + got, err := e.stageDCO(context.Background(), store, key, obs, policy) + if err != nil || got.unsigned != 1 || got.unsignedHive != 1 || got.unsignedOther != 0 || api.commitReads != 1 { + t.Fatalf("legacy split: %+v, %v, reads=%d; want hive=1 other=0 after one read", got, err, api.commitReads) + } + store.NoteDCO(key, obs.HeadSHA, got.total, got.unsigned, got.unsignedHive, got.squashUnsafeHive) + got, err = e.stageDCO(context.Background(), store, key, obs, policy) + if err != nil || got.unsignedHive != 1 || got.unsignedOther != 0 || api.commitReads != 1 { + t.Fatalf("refreshed split: %+v, %v, reads=%d; want the cache served", got, err, api.commitReads) + } +} + // hivecommons/hive#12557: a gate flapping between merge-queue and a pending // stage on one unchanged head used to post a stage-regressed comment every // sweep, because each recover re-armed the dedupe. One comment per head. diff --git a/src/pkg/stagelabels/stagelabels_test.go b/src/pkg/stagelabels/stagelabels_test.go index ed269369d3..56dbe14573 100644 --- a/src/pkg/stagelabels/stagelabels_test.go +++ b/src/pkg/stagelabels/stagelabels_test.go @@ -1027,6 +1027,18 @@ func TestStoreNoteDCOSplitAndAdoptReason(t *testing.T) { } } +// hivecommons/hive#16701: NoteDCO marks the split as computed with hive +// identities, including on a legacy record whose counts are unchanged. +func TestStoreNoteDCOMarksHiveIdentitySplit(t *testing.T) { + s := NewStore("", nil) + key := Key("acme/widget", 8) + s.items[key] = Record{DCOHead: "a", DCOTotal: 2, DCOUnsigned: 1, DCOUnsignedOther: 1, DCOSquashUnsafeKnown: true} + s.NoteDCO(key, "a", 2, 1, 0, 0) + if r, _ := s.Get(key); !r.DCOSplitHiveIdentity || r.DCOUnsignedOther != 1 { + t.Fatalf("legacy record not marked: %+v", r) + } +} + func TestStoreAdoptInPlaceAndYield(t *testing.T) { now := time.Date(2026, 10, 16, 12, 0, 0, 0, time.UTC) s := NewStore("", func() time.Time { return now }) diff --git a/src/pkg/stagelabels/store.go b/src/pkg/stagelabels/store.go index 3161f35218..0b2bdbedce 100644 --- a/src/pkg/stagelabels/store.go +++ b/src/pkg/stagelabels/store.go @@ -159,6 +159,10 @@ type Record struct { DCOUnsignedOther int `json:"dco_unsigned_other,omitempty"` DCOSquashUnsafeHive int `json:"dco_squash_unsafe_hive,omitempty"` DCOSquashUnsafeKnown bool `json:"dco_squash_unsafe_known,omitempty"` + // DCOSplitHiveIdentity marks a split computed with the hive's own + // identities (project.ai_author) counted as the hive's; records cached + // before that (hivecommons/hive#16701) lack it and are read again once. + DCOSplitHiveIdentity bool `json:"dco_split_hive_identity,omitempty"` // EntryCommented records that the stage's entry comment (085 "needs a // decision", 090 "ready for a human merge") was posted for the current // stage visit; reset on every stage change so each transition explains @@ -2469,8 +2473,8 @@ func (s *Store) NoteHold(key string, hold *HoldProvenance) { func (s *Store) ClearHold(key string) { s.NoteHold(key, nil) } // NoteDCO caches the commit check for head on an existing record: -// unsignedHive is the App-linked share of the unsigned commits, the rest -// is recorded as other. +// unsignedHive is the hive's share of the unsigned commits (App bot or a +// hive identity), the rest is recorded as other. func (s *Store) NoteDCO(key, head string, total, unsigned, unsignedHive, squashUnsafeHive int) { if head == "" { return @@ -2481,11 +2485,12 @@ func (s *Store) NoteDCO(key, head string, total, unsigned, unsignedHive, squashU s.mu.Lock() defer s.mu.Unlock() r, ok := s.items[key] - if !ok || (r.DCOHead == head && r.DCOTotal == total && r.DCOUnsigned == unsigned && r.DCOUnsignedHive == unsignedHive && r.DCOUnsignedOther == other && r.DCOSquashUnsafeHive == squashUnsafeHive && r.DCOSquashUnsafeKnown) { + if !ok || (r.DCOHead == head && r.DCOTotal == total && r.DCOUnsigned == unsigned && r.DCOUnsignedHive == unsignedHive && r.DCOUnsignedOther == other && r.DCOSquashUnsafeHive == squashUnsafeHive && r.DCOSquashUnsafeKnown && r.DCOSplitHiveIdentity) { return } r.DCOHead, r.DCOTotal, r.DCOUnsigned, r.DCOUnsignedHive, r.DCOUnsignedOther, r.DCOSquashUnsafeHive = head, total, unsigned, unsignedHive, other, squashUnsafeHive r.DCOSquashUnsafeKnown = true + r.DCOSplitHiveIdentity = true s.items[key] = r s.dirty = true } From 629ca32231fcec57d83c8acad6357b2f51d4a3cb Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 03:05:24 +0000 Subject: [PATCH 05/13] test(crux/cline): cover provider-file denials in the worker (#16705) The --provider-file consumer side of cline.run only had a positive test: nothing exercised the guard that refuses a mounted provider file that resolves inside the Git workspace (directly or through a symlink), the unreadable-mount branch, or a narrowed file that fails credential narrowing. Each case now asserts the turn exits 1 with the specific denial, leaks no credential value, and never launches the Cline CLI. Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/crux/cline/provider_file_test.go | 67 ++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/src/crux/cline/provider_file_test.go b/src/crux/cline/provider_file_test.go index 7f8c20421b..fc931bd1d4 100644 --- a/src/crux/cline/provider_file_test.go +++ b/src/crux/cline/provider_file_test.go @@ -195,3 +195,70 @@ func TestProviderStagingRootAndRedactionFailures(t *testing.T) { t.Fatal("nested or overlapping secret redaction failed") } } + +func TestMountedProviderWorkerDenials(t *testing.T) { + root, workspace := t.TempDir(), t.TempDir() + t.Setenv("HOME", root) + t.Setenv("HIVE_CLINE_CONFIG_DIR", "") + source := filepath.Join(root, "source") + credentials(t, source, providerConfig) + p, err := StageProviderFile(source, "openrouter/test", workspace) + if err != nil { + t.Fatal(err) + } + defer p.Close() + mounted, err := p.MountFile(workspace) + if err != nil { + t.Fatal(err) + } + narrowed, err := os.ReadFile(mounted) + if err != nil { + t.Fatal(err) + } + // A denied provider file must never reach inference: the stub leaves a + // marker when launched, and none of the cases below may create it. + launched := filepath.Join(root, "launched") + binary := fakeCLI(t, "touch "+launched+`; cat >/dev/null; echo '{"type":"run_result","finishReason":"completed","text":"done"}'`) + write := func(path string, body []byte) string { + t.Helper() + if err := os.WriteFile(path, body, 0o600); err != nil { + t.Fatal(err) + } + return path + } + inWorkspace := write(filepath.Join(workspace, "providers.json"), narrowed) + viaSymlink := filepath.Join(root, "outside-link") + if err := os.Symlink(inWorkspace, viaSymlink); err != nil { + t.Fatal(err) + } + unreadable := filepath.Join(root, "directory-not-file") + if err := os.Mkdir(unreadable, 0o700); err != nil { + t.Fatal(err) + } + cases := []struct { + name, file, want string + }{ + {"inside workspace", inWorkspace, "outside the Git workspace"}, + {"symlink into workspace", viaSymlink, "outside the Git workspace"}, + {"missing", filepath.Join(root, "missing"), "cannot resolve"}, + {"unreadable", unreadable, "cannot read the mounted selected Cline provider"}, + {"unsupported schema", write(filepath.Join(root, "schema.json"), []byte(`{"version":2}`)), "unsupported Cline providers.json schema"}, + {"other provider only", write(filepath.Join(root, "other.json"), []byte(`{"version":1,"providers":{"other":{"settings":{"apiKey":"test-key"}}}}`)), "not configured"}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + var out, errOut bytes.Buffer + code := Run([]string{"--cline", binary, "--model", "openrouter/test", "--provider-file", tc.file, + "--cwd", workspace, "--state-dir", filepath.Join(root, "state")}, strings.NewReader("bounded task"), &out, &errOut) + if code != 1 || !strings.Contains(errOut.String(), tc.want) { + t.Fatalf("code %d, stderr %q", code, &errOut) + } + if strings.Contains(errOut.String(), "test-key") || strings.Contains(out.String(), "test-key") { + t.Fatal("denial leaked the provider credential") + } + if _, err := os.Stat(launched); !os.IsNotExist(err) { + t.Fatal("denied provider file still launched the Cline CLI") + } + }) + } +} From 1b1d4a6f2020f82ca394f91ee54c4cec2678bdad Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 03:23:06 +0000 Subject: [PATCH 06/13] =?UTF-8?q?=F0=9F=90=9B=20fix(dco):=20only=20flag=20?= =?UTF-8?q?hive-identity=20DCO=20splits=20so=20a=20later=20ai=5Fauthor=20c?= =?UTF-8?q?onfig=20triggers=20the=20re-read=20(#16709)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-16707.md | 1 + .../automerge/automerge_stage_labels.go | 2 +- .../automerge/automerge_stage_labels_test.go | 2 +- .../automerge/shared_ci_attribution_test.go | 2 +- src/pkg/stagelabels/stagelabels_test.go | 24 +++++++++++++++---- src/pkg/stagelabels/store.go | 12 ++++++---- 6 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 changelog.d/fixed-16707.md diff --git a/changelog.d/fixed-16707.md b/changelog.d/fixed-16707.md new file mode 100644 index 0000000000..97449a01cd --- /dev/null +++ b/changelog.d/fixed-16707.md @@ -0,0 +1 @@ +- A DCO split cached while no `project.ai_author` was configured is no longer treated as computed with the hive identity, so configuring it later re-reads the commits for in-flight heads ([#16707](https://github.com/hivecommons/hive/issues/16707)). diff --git a/src/pkg/github/automerge/automerge_stage_labels.go b/src/pkg/github/automerge/automerge_stage_labels.go index e4adeb5fa5..bfd2b11315 100644 --- a/src/pkg/github/automerge/automerge_stage_labels.go +++ b/src/pkg/github/automerge/automerge_stage_labels.go @@ -1190,7 +1190,7 @@ func (c *Engine) ApplyStageLabels(ctx context.Context) (StageLabelResult, error) soakFirstGreen, _ := c.contributorSoak.FirstGreen(obs.Owner, obs.Repo, obs.Number, obs.HeadSHA) noteSoak(store, key, obs.Reason, obs.HeadSHA, pass.Route, c.currentContributorLanePolicy().Soak, soakFirstGreen, now) if dcoRead { - store.NoteDCO(key, obs.HeadSHA, obs.Detail.DCOTotal, obs.Detail.DCOUnsigned, obs.Detail.DCOUnsignedHive, obs.Detail.DCOSquashUnsafeHive) + store.NoteDCO(key, obs.HeadSHA, obs.Detail.DCOTotal, obs.Detail.DCOUnsigned, obs.Detail.DCOUnsignedHive, obs.Detail.DCOSquashUnsafeHive, policy.HiveAuthor != nil) } if verdict.Stage != stagelabels.ReturnedToContributor && verdict.Stage != stagelabels.NeedsAuthor { c.resolveNudge(ctx, prevRec, hadPrev, obs) diff --git a/src/pkg/github/automerge/automerge_stage_labels_test.go b/src/pkg/github/automerge/automerge_stage_labels_test.go index e8059712d8..dc1fcdf8fb 100644 --- a/src/pkg/github/automerge/automerge_stage_labels_test.go +++ b/src/pkg/github/automerge/automerge_stage_labels_test.go @@ -2489,7 +2489,7 @@ func TestStageDCORereadsSplitCachedBeforeHiveIdentities(t *testing.T) { if err != nil || got.unsigned != 1 || got.unsignedHive != 1 || got.unsignedOther != 0 || api.commitReads != 1 { t.Fatalf("legacy split: %+v, %v, reads=%d; want hive=1 other=0 after one read", got, err, api.commitReads) } - store.NoteDCO(key, obs.HeadSHA, got.total, got.unsigned, got.unsignedHive, got.squashUnsafeHive) + store.NoteDCO(key, obs.HeadSHA, got.total, got.unsigned, got.unsignedHive, got.squashUnsafeHive, true) got, err = e.stageDCO(context.Background(), store, key, obs, policy) if err != nil || got.unsignedHive != 1 || got.unsignedOther != 0 || api.commitReads != 1 { t.Fatalf("refreshed split: %+v, %v, reads=%d; want the cache served", got, err, api.commitReads) diff --git a/src/pkg/github/automerge/shared_ci_attribution_test.go b/src/pkg/github/automerge/shared_ci_attribution_test.go index 1e20a6a6d3..0716ff0aee 100644 --- a/src/pkg/github/automerge/shared_ci_attribution_test.go +++ b/src/pkg/github/automerge/shared_ci_attribution_test.go @@ -42,7 +42,7 @@ func TestStageDCONormalizesCachedBotAttributionWithoutChangingSignoffs(t *testin e, _, store := newStageEngine(t, srv.URL, &contributorLaneClock{at: time.Now()}) key := stageKey("acme", "widget", 42) store.Observe(key, stagelabels.Fixing, stagelabels.LaneReasonHiveSignoffAttribution) - store.NoteDCO(key, "aaa", 3, 0, 0, 1) + store.NoteDCO(key, "aaa", 3, 0, 0, 1, true) got, err := e.stageDCO(context.Background(), store, key, stageObservation{ Owner: "acme", Repo: "widget", Number: 42, HeadSHA: "aaa", Author: "dependabot[bot]", }, StageLabelPolicy{}) diff --git a/src/pkg/stagelabels/stagelabels_test.go b/src/pkg/stagelabels/stagelabels_test.go index 56dbe14573..73ffb6cac3 100644 --- a/src/pkg/stagelabels/stagelabels_test.go +++ b/src/pkg/stagelabels/stagelabels_test.go @@ -998,18 +998,18 @@ func TestStoreNoteDCOSplitAndAdoptReason(t *testing.T) { now := time.Date(2026, 10, 16, 12, 0, 0, 0, time.UTC) s := NewStore("", func() time.Time { return now }) key := Key("acme/widget", 7) - s.NoteDCO(key, "a", 3, 2, 1, 0) + s.NoteDCO(key, "a", 3, 2, 1, 0, true) s.NoteAdoptReason(key, "dco-rehome") if _, ok := s.Get(key); ok { t.Fatal("NoteDCO/NoteAdoptReason created a record") } s.Observe(key, ReturnedToContributor, "check-failing:dco") - s.NoteDCO(key, "a", 3, 2, 1, 0) + s.NoteDCO(key, "a", 3, 2, 1, 0, true) r, _ := s.Get(key) if t0, u, ok := r.DCOFor("a"); !ok || t0 != 3 || u != 2 || r.DCOUnsignedHive != 1 || r.DCOUnsignedOther != 1 || !r.DCOSplitKnown("a") || r.DCOSplitKnown("b") { t.Fatalf("cached split: %+v", r) } - s.NoteDCO(key, "a", 3, 2, 2, 0) + s.NoteDCO(key, "a", 3, 2, 2, 0, true) if r, _ = s.Get(key); r.DCOUnsignedHive != 2 || r.DCOUnsignedOther != 0 || !r.DCOSplitKnown("a") { t.Fatalf("hive share not updated: %+v", r) } @@ -1033,12 +1033,28 @@ func TestStoreNoteDCOMarksHiveIdentitySplit(t *testing.T) { s := NewStore("", nil) key := Key("acme/widget", 8) s.items[key] = Record{DCOHead: "a", DCOTotal: 2, DCOUnsigned: 1, DCOUnsignedOther: 1, DCOSquashUnsafeKnown: true} - s.NoteDCO(key, "a", 2, 1, 0, 0) + s.NoteDCO(key, "a", 2, 1, 0, 0, true) if r, _ := s.Get(key); !r.DCOSplitHiveIdentity || r.DCOUnsignedOther != 1 { t.Fatalf("legacy record not marked: %+v", r) } } +// hivecommons/hive#16707: an App-only split (no hive identity configured) +// must not be marked, so configuring one later triggers the re-read. +func TestStoreNoteDCOAppOnlySplitNotMarked(t *testing.T) { + s := NewStore("", nil) + key := Key("acme/widget", 9) + s.items[key] = Record{DCOHead: "a", DCOTotal: 2, DCOUnsigned: 1, DCOUnsignedOther: 1, DCOSquashUnsafeKnown: true} + s.NoteDCO(key, "a", 2, 1, 1, 0, false) + if r, _ := s.Get(key); r.DCOSplitHiveIdentity || r.DCOUnsignedHive != 1 { + t.Fatalf("app-only split marked or not stored: %+v", r) + } + s.NoteDCO(key, "a", 2, 1, 1, 0, true) + if r, _ := s.Get(key); !r.DCOSplitHiveIdentity { + t.Fatalf("hive-identity split not marked: %+v", r) + } +} + func TestStoreAdoptInPlaceAndYield(t *testing.T) { now := time.Date(2026, 10, 16, 12, 0, 0, 0, time.UTC) s := NewStore("", func() time.Time { return now }) diff --git a/src/pkg/stagelabels/store.go b/src/pkg/stagelabels/store.go index 0b2bdbedce..afd0af8b70 100644 --- a/src/pkg/stagelabels/store.go +++ b/src/pkg/stagelabels/store.go @@ -2474,8 +2474,10 @@ func (s *Store) ClearHold(key string) { s.NoteHold(key, nil) } // NoteDCO caches the commit check for head on an existing record: // unsignedHive is the hive's share of the unsigned commits (App bot or a -// hive identity), the rest is recorded as other. -func (s *Store) NoteDCO(key, head string, total, unsigned, unsignedHive, squashUnsafeHive int) { +// hive identity), the rest is recorded as other. hiveIdentity says the split +// was computed with a hive identity configured; an App-only split leaves the +// marker unset so configuring one later triggers the one-time re-read. +func (s *Store) NoteDCO(key, head string, total, unsigned, unsignedHive, squashUnsafeHive int, hiveIdentity bool) { if head == "" { return } @@ -2485,12 +2487,14 @@ func (s *Store) NoteDCO(key, head string, total, unsigned, unsignedHive, squashU s.mu.Lock() defer s.mu.Unlock() r, ok := s.items[key] - if !ok || (r.DCOHead == head && r.DCOTotal == total && r.DCOUnsigned == unsigned && r.DCOUnsignedHive == unsignedHive && r.DCOUnsignedOther == other && r.DCOSquashUnsafeHive == squashUnsafeHive && r.DCOSquashUnsafeKnown && r.DCOSplitHiveIdentity) { + if !ok || (r.DCOHead == head && r.DCOTotal == total && r.DCOUnsigned == unsigned && r.DCOUnsignedHive == unsignedHive && r.DCOUnsignedOther == other && r.DCOSquashUnsafeHive == squashUnsafeHive && r.DCOSquashUnsafeKnown && (r.DCOSplitHiveIdentity || !hiveIdentity)) { return } r.DCOHead, r.DCOTotal, r.DCOUnsigned, r.DCOUnsignedHive, r.DCOUnsignedOther, r.DCOSquashUnsafeHive = head, total, unsigned, unsignedHive, other, squashUnsafeHive r.DCOSquashUnsafeKnown = true - r.DCOSplitHiveIdentity = true + if hiveIdentity { + r.DCOSplitHiveIdentity = true + } s.items[key] = r s.dirty = true } From c142df44ba6e900072f292e6b7e847f05e7fd06b Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 03:47:56 +0000 Subject: [PATCH 07/13] fix(dco): clear the hive-identity split marker when a new head is cached App-only (#16712) NoteDCO only ever set DCOSplitHiveIdentity. After ai_author was removed, a new head cached App-only kept a stale true marker from the previous head; re-adding ai_author then made stageDCO trust the marker and serve the App-only split instead of re-reading. Set the marker from hiveIdentity when the head changes; same-head refreshes still never clear a true flag. Closes #16710 Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-16710.md | 1 + src/pkg/stagelabels/stagelabels_test.go | 17 +++++++++++++++++ src/pkg/stagelabels/store.go | 5 +++-- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 changelog.d/fixed-16710.md diff --git a/changelog.d/fixed-16710.md b/changelog.d/fixed-16710.md new file mode 100644 index 0000000000..b3a82301a4 --- /dev/null +++ b/changelog.d/fixed-16710.md @@ -0,0 +1 @@ +- A stale hive-identity DCO marker is now cleared when a new head is cached App-only, so re-adding `ai_author` after removing it re-reads the commit check instead of serving the App-only split ([#16710](https://github.com/hivecommons/hive/issues/16710)). diff --git a/src/pkg/stagelabels/stagelabels_test.go b/src/pkg/stagelabels/stagelabels_test.go index 73ffb6cac3..a0fb8906a3 100644 --- a/src/pkg/stagelabels/stagelabels_test.go +++ b/src/pkg/stagelabels/stagelabels_test.go @@ -1055,6 +1055,23 @@ func TestStoreNoteDCOAppOnlySplitNotMarked(t *testing.T) { } } +// hivecommons/hive#16710: a new head cached App-only must clear a stale +// hive-identity marker; a same-head App-only refresh must keep it. +func TestStoreNoteDCONewHeadClearsHiveIdentityMarker(t *testing.T) { + s := NewStore("", nil) + key := Key("acme/widget", 10) + s.items[key] = Record{DCOHead: "a", DCOTotal: 2, DCOUnsigned: 1, DCOUnsignedOther: 1, DCOSquashUnsafeKnown: true} + s.NoteDCO(key, "a", 2, 1, 0, 0, true) + s.NoteDCO(key, "a", 2, 1, 0, 0, false) + if r, _ := s.Get(key); !r.DCOSplitHiveIdentity { + t.Fatalf("same-head App-only refresh cleared the marker: %+v", r) + } + s.NoteDCO(key, "b", 2, 1, 1, 0, false) + if r, _ := s.Get(key); r.DCOSplitHiveIdentity || r.DCOHead != "b" { + t.Fatalf("stale marker survived a new App-only head: %+v", r) + } +} + func TestStoreAdoptInPlaceAndYield(t *testing.T) { now := time.Date(2026, 10, 16, 12, 0, 0, 0, time.UTC) s := NewStore("", func() time.Time { return now }) diff --git a/src/pkg/stagelabels/store.go b/src/pkg/stagelabels/store.go index afd0af8b70..48b5a97f1f 100644 --- a/src/pkg/stagelabels/store.go +++ b/src/pkg/stagelabels/store.go @@ -2490,10 +2490,11 @@ func (s *Store) NoteDCO(key, head string, total, unsigned, unsignedHive, squashU if !ok || (r.DCOHead == head && r.DCOTotal == total && r.DCOUnsigned == unsigned && r.DCOUnsignedHive == unsignedHive && r.DCOUnsignedOther == other && r.DCOSquashUnsafeHive == squashUnsafeHive && r.DCOSquashUnsafeKnown && (r.DCOSplitHiveIdentity || !hiveIdentity)) { return } + headChanged := r.DCOHead != head r.DCOHead, r.DCOTotal, r.DCOUnsigned, r.DCOUnsignedHive, r.DCOUnsignedOther, r.DCOSquashUnsafeHive = head, total, unsigned, unsignedHive, other, squashUnsafeHive r.DCOSquashUnsafeKnown = true - if hiveIdentity { - r.DCOSplitHiveIdentity = true + if headChanged || hiveIdentity { + r.DCOSplitHiveIdentity = hiveIdentity } s.items[key] = r s.dirty = true From f4cd81bbd08f4a8042300d36d93036c952fdda72 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Thu, 5 Nov 2026 00:37:29 -0500 Subject: [PATCH 08/13] =?UTF-8?q?=F0=9F=8C=B1=20images:=20bump=20agy=201.4?= =?UTF-8?q?.0,5281842794987520=20->=201.5.0,5269980577660928=20(#16720)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated pin bump (#8419). Digests recomputed from the downloaded release artifacts by src/scripts/cli-pin-bump.sh: VERSION=1.5.0 BUILD=5269980577660928 SHA256_AMD64=f65e365a67be49abdaf92f5669c3157bd4b9c569f6b9f448340b00ca261b0f01 SHA512_AMD64=e6031f850929210705d8c2393a5665b82b8c3b19684a6d3c556cafa31f26f77acbf164dfee96ca84a5ae7670ac0cc238a974c981c517b269194bdccff271cbd5 SHA256_ARM64=87e73a5ab4ecb3a9668660d259dafd13f5443149da0113664d59129a21a62ba4 SHA512_ARM64=509518b2820945db2bea5e013ca43a49df5c78927c3ac341a1115287d52627356e1e9506ac0d2040fb467915fba4dde90061d091fddbddf8ddc212637ae40150 Signed-off-by: hive-release[bot] Signed-off-by: clubanderson <407614+clubanderson@users.noreply.github.com> Co-authored-by: hive-release[bot] --- src/Dockerfile | 8 ++++---- src/Dockerfile.contributor | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Dockerfile b/src/Dockerfile index 0ae1bf25eb..d10e75987e 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -382,10 +382,10 @@ RUN ARCH="${TARGETARCH:-$(dpkg --print-architecture)}" && \ # complete the interactive OAuth flow itself). This enables a self-hosted Hive # controller to use its configured agy fallback rung without pretending that # generic contributor containers can bootstrap Google login. -ARG AGY_VERSION=1.4.0 -ARG AGY_BUILD=5281842794987520 -ARG AGY_SHA512_AMD64=6c4b298c2a69b6bd0f58567031cc56d8097a32be54c4b633aa80ad395871b389618ab3860d4ba0a12599831b8226b51b03e258ee2ec7fae105a45b8e0fce2188 -ARG AGY_SHA512_ARM64=64dfb2a9665ebd19b6e9d687c094673b61ca9f5ffdebc81391cea8e3858773e1c88154f088e8a8691208561d946a7aea9acbec7a3bdca9e5d8a48fa197b0a308 +ARG AGY_VERSION=1.5.0 +ARG AGY_BUILD=5269980577660928 +ARG AGY_SHA512_AMD64=e6031f850929210705d8c2393a5665b82b8c3b19684a6d3c556cafa31f26f77acbf164dfee96ca84a5ae7670ac0cc238a974c981c517b269194bdccff271cbd5 +ARG AGY_SHA512_ARM64=509518b2820945db2bea5e013ca43a49df5c78927c3ac341a1115287d52627356e1e9506ac0d2040fb467915fba4dde90061d091fddbddf8ddc212637ae40150 RUN ARCH="${TARGETARCH:-$(dpkg --print-architecture)}" && \ case "$ARCH" in \ amd64|x86_64) AGY_URL_ARCH=x64; AGY_FILE_ARCH=x64; AGY_SHA512="$AGY_SHA512_AMD64" ;; \ diff --git a/src/Dockerfile.contributor b/src/Dockerfile.contributor index 22d91ca230..a4d4aa3c88 100644 --- a/src/Dockerfile.contributor +++ b/src/Dockerfile.contributor @@ -409,9 +409,9 @@ RUN ARCH="${TARGETARCH:-$(dpkg --print-architecture)}" \ # API-key mode, so a fresh container still needs an operator to sign in # inside it (or a future credential-mount fix, see Justfile's `agy)` staging # case) before it can do unattended work. -ARG AGY_VERSION=1.4.0-5281842794987520 -ARG AGY_SHA256_AMD64=fd96967583c1eed94733c039638fa59b71ddbd823c75ebc8dd0e677463565aad -ARG AGY_SHA256_ARM64=cf953adcc69f87d00d71f97c3f35dc723a8669a350accf9a199df781f0523f56 +ARG AGY_VERSION=1.5.0-5269980577660928 +ARG AGY_SHA256_AMD64=f65e365a67be49abdaf92f5669c3157bd4b9c569f6b9f448340b00ca261b0f01 +ARG AGY_SHA256_ARM64=87e73a5ab4ecb3a9668660d259dafd13f5443149da0113664d59129a21a62ba4 RUN ARCH="${TARGETARCH:-$(dpkg --print-architecture)}" \ && case "$ARCH" in \ amd64) AGY_PLATFORM=linux-x64; AGY_TARBALL=cli_linux_x64.tar.gz; AGY_SHA256="$AGY_SHA256_AMD64" ;; \ From 0c39413d4c2c5486b936dc2abf66e7d134051e5a Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 06:17:37 +0000 Subject: [PATCH 09/13] refactor(crux): share follow-stream overlap rule via internal/streamtail (#16723) Signed-off-by: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/changed-crux-streamtail.md | 1 + src/crux/cli/cli_test.go | 19 ----------- src/crux/cli/commands.go | 31 ++---------------- src/crux/internal/streamtail/streamtail.go | 30 +++++++++++++++++ .../internal/streamtail/streamtail_test.go | 25 +++++++++++++++ src/crux/serve/serve_follow.go | 32 ++----------------- src/crux/serve/serve_test.go | 14 +------- 7 files changed, 61 insertions(+), 91 deletions(-) create mode 100644 changelog.d/changed-crux-streamtail.md create mode 100644 src/crux/internal/streamtail/streamtail.go create mode 100644 src/crux/internal/streamtail/streamtail_test.go diff --git a/changelog.d/changed-crux-streamtail.md b/changelog.d/changed-crux-streamtail.md new file mode 100644 index 0000000000..3743f6b0d1 --- /dev/null +++ b/changelog.d/changed-crux-streamtail.md @@ -0,0 +1 @@ +- crux: the follow-stream overlap rule shared by the CLI and the serve layer now lives in one `internal/streamtail` package instead of two copies. diff --git a/src/crux/cli/cli_test.go b/src/crux/cli/cli_test.go index 4c01be43e8..d5acdcf260 100644 --- a/src/crux/cli/cli_test.go +++ b/src/crux/cli/cli_test.go @@ -444,25 +444,6 @@ func TestRunStopErrorAndOutputError(t *testing.T) { } } -func TestNewTail(t *testing.T) { - cases := []struct { - prev, cur, want []string - }{ - {nil, []string{"a", "b"}, []string{"a", "b"}}, - {[]string{"a", "b"}, []string{"a", "b"}, nil}, - {[]string{"a", "b"}, []string{"a", "b", "c"}, []string{"c"}}, - {[]string{"a", "b", "c"}, []string{"b", "c", "d", "e"}, []string{"d", "e"}}, - {[]string{"a", "b"}, []string{"x", "y"}, []string{"x", "y"}}, - {[]string{"a", "b"}, []string{"b"}, nil}, - } - for _, c := range cases { - got := newTail(c.prev, c.cur) - if strings.Join(got, ",") != strings.Join(c.want, ",") { - t.Errorf("newTail(%v, %v) = %v, want %v", c.prev, c.cur, got, c.want) - } - } -} - func hiveYAML(t *testing.T) string { t.Helper() dir := t.TempDir() diff --git a/src/crux/cli/commands.go b/src/crux/cli/commands.go index 02def517c5..5571a6f106 100644 --- a/src/crux/cli/commands.go +++ b/src/crux/cli/commands.go @@ -13,6 +13,7 @@ import ( "time" "github.com/hivecommons/hive/crux" + "github.com/hivecommons/hive/crux/internal/streamtail" ) // subFlags builds a subcommand flag set that reports to stderr and never @@ -130,7 +131,7 @@ func (e *Env) stream(ctx context.Context, rt crux.Runtime, name string, interval fmt.Fprintf(e.Stderr, "crux: output %s: %v\n", name, err) return } - for _, line := range newTail(prev, cur) { + for _, line := range streamtail.Fresh(prev, cur) { fmt.Fprintln(e.Stdout, line) } prev = cur @@ -138,34 +139,6 @@ func (e *Env) stream(ctx context.Context, rt crux.Runtime, name string, interval } } -// newTail returns the lines of cur that were not already printed from prev, -// treating both as windows onto the same append-only buffer: the longest -// suffix of prev that is a prefix of cur is the overlap. -func newTail(prev, cur []string) []string { - max := len(prev) - if len(cur) < max { - max = len(cur) - } - for k := max; k > 0; k-- { - if equalLines(prev[len(prev)-k:], cur[:k]) { - return cur[k:] - } - } - return cur -} - -func equalLines(a, b []string) bool { - if len(a) != len(b) { - return false - } - for i := range a { - if a[i] != b[i] { - return false - } - } - return true -} - // processRow is the ps projection of a crux.Process: the columns an operator // reads at a glance, and the JSON shape --json emits. type processRow struct { diff --git a/src/crux/internal/streamtail/streamtail.go b/src/crux/internal/streamtail/streamtail.go new file mode 100644 index 0000000000..afdbd9059d --- /dev/null +++ b/src/crux/internal/streamtail/streamtail.go @@ -0,0 +1,30 @@ +// Package streamtail computes the unseen part of a polled output window. +package streamtail + +// Fresh returns the lines of cur that were not already seen in prev, treating +// both as windows onto the same append-only buffer: the longest suffix of prev +// that is a prefix of cur is the overlap. +func Fresh(prev, cur []string) []string { + max := len(prev) + if len(cur) < max { + max = len(cur) + } + for k := max; k > 0; k-- { + if equalLines(prev[len(prev)-k:], cur[:k]) { + return cur[k:] + } + } + return cur +} + +func equalLines(a, b []string) bool { + if len(a) != len(b) { + return false + } + for i := range a { + if a[i] != b[i] { + return false + } + } + return true +} diff --git a/src/crux/internal/streamtail/streamtail_test.go b/src/crux/internal/streamtail/streamtail_test.go new file mode 100644 index 0000000000..76a9872ab7 --- /dev/null +++ b/src/crux/internal/streamtail/streamtail_test.go @@ -0,0 +1,25 @@ +package streamtail + +import ( + "strings" + "testing" +) + +func TestFresh(t *testing.T) { + cases := []struct { + prev, cur, want []string + }{ + {nil, []string{"a", "b"}, []string{"a", "b"}}, + {[]string{"a", "b"}, []string{"a", "b"}, nil}, + {[]string{"a", "b"}, []string{"a", "b", "c"}, []string{"c"}}, + {[]string{"a", "b", "c"}, []string{"b", "c", "d", "e"}, []string{"d", "e"}}, + {[]string{"a", "b"}, []string{"x", "y"}, []string{"x", "y"}}, + {[]string{"a", "b"}, []string{"b"}, nil}, + {[]string{"a", "b", "c"}, []string{"c"}, nil}, + } + for _, c := range cases { + if got := Fresh(c.prev, c.cur); strings.Join(got, ",") != strings.Join(c.want, ",") { + t.Errorf("Fresh(%v, %v) = %v, want %v", c.prev, c.cur, got, c.want) + } + } +} diff --git a/src/crux/serve/serve_follow.go b/src/crux/serve/serve_follow.go index 151b23f2f3..5c62b3cc3e 100644 --- a/src/crux/serve/serve_follow.go +++ b/src/crux/serve/serve_follow.go @@ -7,6 +7,7 @@ import ( "github.com/hivecommons/hive/crux" "github.com/hivecommons/hive/crux/api" + "github.com/hivecommons/hive/crux/internal/streamtail" ) // followWindow is how many ring-buffer lines each follow poll asks for when @@ -74,7 +75,7 @@ func (s *Server) followLogs(w http.ResponseWriter, r *http.Request, name string, flusher.Flush() return } - if fresh := newTail(prev, cur); len(fresh) > 0 { + if fresh := streamtail.Fresh(prev, cur); len(fresh) > 0 { if api.WriteEvent(w, api.EventLog, api.LogChunk{Agent: name, Lines: fresh}) != nil { return } @@ -92,32 +93,3 @@ func lastLines(lines []string, n int) []string { } return lines[len(lines)-n:] } - -// newTail returns the lines of cur that were not already seen in prev, -// treating both as windows onto the same append-only buffer: the longest -// suffix of prev that is a prefix of cur is the overlap. It is the CLI's -// stream rule (crux/cli.newTail) applied server side. -func newTail(prev, cur []string) []string { - max := len(prev) - if len(cur) < max { - max = len(cur) - } - for k := max; k > 0; k-- { - if equalLines(prev[len(prev)-k:], cur[:k]) { - return cur[k:] - } - } - return cur -} - -func equalLines(a, b []string) bool { - if len(a) != len(b) { - return false - } - for i := range a { - if a[i] != b[i] { - return false - } - } - return true -} diff --git a/src/crux/serve/serve_test.go b/src/crux/serve/serve_test.go index e256692c1c..dd6c8ac238 100644 --- a/src/crux/serve/serve_test.go +++ b/src/crux/serve/serve_test.go @@ -1221,7 +1221,7 @@ func TestWriteJSONLogsEncodeFailures(t *testing.T) { func slogTo(w io.Writer) *slog.Logger { return slog.New(slog.NewTextHandler(w, nil)) } -func TestIsTrueAndNewTail(t *testing.T) { +func TestIsTrue(t *testing.T) { for _, v := range []string{"1", "true", "YES", "on"} { if !isTrue(v) { t.Errorf("%q should be true", v) @@ -1232,16 +1232,4 @@ func TestIsTrueAndNewTail(t *testing.T) { t.Errorf("%q should be false", v) } } - cases := []struct{ prev, cur, want []string }{ - {nil, []string{"a"}, []string{"a"}}, - {[]string{"a", "b"}, []string{"a", "b"}, nil}, - {[]string{"a", "b"}, []string{"b", "c"}, []string{"c"}}, - {[]string{"a", "b"}, []string{"x", "y"}, []string{"x", "y"}}, - {[]string{"a", "b", "c"}, []string{"c"}, nil}, - } - for _, c := range cases { - if got := newTail(c.prev, c.cur); strings.Join(got, ",") != strings.Join(c.want, ",") { - t.Errorf("newTail(%v,%v) = %v, want %v", c.prev, c.cur, got, c.want) - } - } } From 3b56541107e774a07bb93edf6ca7febf6f29d14c Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 06:54:21 +0000 Subject: [PATCH 10/13] fix(cmd/hive): decouple crux probe deadline from poll interval (#16727) The sidecar probe reused the poll interval as its HTTP deadline, so the 20ms test ticker starved the probe under a loaded runner and reported a live crux serve as down (coverage run 41974171725). Closes #16721 Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-16721.md | 1 + src/cmd/hive/agent_runtime_supervise.go | 13 ++++++++----- src/cmd/hive/agent_runtime_supervise_test.go | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 changelog.d/fixed-16721.md diff --git a/changelog.d/fixed-16721.md b/changelog.d/fixed-16721.md new file mode 100644 index 0000000000..d87d18044e --- /dev/null +++ b/changelog.d/fixed-16721.md @@ -0,0 +1 @@ +- Decouple the crux sidecar probe deadline from the poll interval so a fast test ticker no longer reports a live `crux serve` as unreachable (#16721). diff --git a/src/cmd/hive/agent_runtime_supervise.go b/src/cmd/hive/agent_runtime_supervise.go index 7aad99df44..ef136dd808 100644 --- a/src/cmd/hive/agent_runtime_supervise.go +++ b/src/cmd/hive/agent_runtime_supervise.go @@ -52,9 +52,12 @@ type cruxRuntimeSupervision struct { prober runtimeProber supervisor *cruxruntime.Supervisor logger *slog.Logger - interval time.Duration - observe func(class, key, message, diagnostics string) - clear func(class, key string) + // interval is the poll-loop period; probeTimeout is the per-probe HTTP + // deadline. They are decoupled so a fast test ticker cannot starve the probe. + interval time.Duration + probeTimeout time.Duration + observe func(class, key, message, diagnostics string) + clear func(class, key string) } // newCruxRuntimeSupervision prepares supervision for rt under cfg. It @@ -76,7 +79,7 @@ func newCruxRuntimeSupervision(cfg cruxconfig.RuntimeConfig, rt crux.Runtime, lo return nil } } - s := &cruxRuntimeSupervision{cfg: cfg, prober: p, logger: logger, interval: cruxRuntimeProbeInterval, observe: fleetreport.Observe, clear: fleetreport.Clear} + s := &cruxRuntimeSupervision{cfg: cfg, prober: p, logger: logger, interval: cruxRuntimeProbeInterval, probeTimeout: cruxRuntimeProbeInterval, observe: fleetreport.Observe, clear: fleetreport.Clear} if cfg.Supervise == cruxconfig.SuperviseChild { s.supervisor = &cruxruntime.Supervisor{Config: cfg, Logger: logger} } @@ -121,7 +124,7 @@ func (s *cruxRuntimeSupervision) watch(ctx context.Context) { // probe makes one health call so the client's Status reflects the socket // even when no agent traffic has exercised it. func (s *cruxRuntimeSupervision) probe(ctx context.Context) { - pctx, cancel := context.WithTimeout(ctx, s.interval) + pctx, cancel := context.WithTimeout(ctx, s.probeTimeout) defer cancel() _, _ = s.prober.Client().Health(pctx) } diff --git a/src/cmd/hive/agent_runtime_supervise_test.go b/src/cmd/hive/agent_runtime_supervise_test.go index b0805cbdf8..fb1d7e5c6e 100644 --- a/src/cmd/hive/agent_runtime_supervise_test.go +++ b/src/cmd/hive/agent_runtime_supervise_test.go @@ -116,6 +116,20 @@ func TestCruxRuntimeSupervision_NilOutsideSidecar(t *testing.T) { } } +func TestCruxRuntimeSupervision_ProbeDeadlineIndependentOfInterval(t *testing.T) { + _, ts := liveServe(t) + s, _, _ := newSupervisionFor(t, ts.URL, cruxconfig.SuperviseExternal) + s.interval = time.Nanosecond + + s.probe(context.Background()) + if down := s.reconcile(false); down { + t.Fatal("live server reported down with a tiny poll interval") + } + if !s.prober.Status().Reachable { + t.Fatal("prober unreachable with a tiny poll interval") + } +} + func TestCruxRuntimeSupervision_ConditionFollowsReachability(t *testing.T) { _, ts := liveServe(t) s, cl, log := newSupervisionFor(t, ts.URL, cruxconfig.SuperviseExternal) From 6da0cf3c3c04883c0a37aecfca8838c464d269d5 Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 07:13:23 +0000 Subject: [PATCH 11/13] fix(stage-labels): warn once per PR when the write-back gate refuses a reopen (#16729) Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-stage-label-reopen-warn-dedupe.md | 1 + src/pkg/github/automerge/automerge_adoption_close_first.go | 5 ++++- .../github/automerge/automerge_adoption_close_first_test.go | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changelog.d/fixed-stage-label-reopen-warn-dedupe.md diff --git a/changelog.d/fixed-stage-label-reopen-warn-dedupe.md b/changelog.d/fixed-stage-label-reopen-warn-dedupe.md new file mode 100644 index 0000000000..42044d4780 --- /dev/null +++ b/changelog.d/fixed-stage-label-reopen-warn-dedupe.md @@ -0,0 +1 @@ +- The stage-label reconciler now warns once per PR head and refusal reason when the write-back gate refuses reopening a hive-closed superseded PR, instead of on every tick. diff --git a/src/pkg/github/automerge/automerge_adoption_close_first.go b/src/pkg/github/automerge/automerge_adoption_close_first.go index d3efdeaba8..d764855eff 100644 --- a/src/pkg/github/automerge/automerge_adoption_close_first.go +++ b/src/pkg/github/automerge/automerge_adoption_close_first.go @@ -313,7 +313,10 @@ func (c *Engine) reopenSupersededOriginal(ctx context.Context, store *stagelabel // Not a pause: the contributor_adopt policy changed after the hive // closed this PR, so the reopen that would undo that close no // longer clears the gate. The PR stays closed until the policy - // allows it again or a person reopens it; say so loudly. + // allows it again or a person reopens it; say so loudly, once per head and refusal. + if !c.markTerminalHoldLogged(owner, repo, number, rec.AdoptedHead, "close-first-reopen-refused:"+d.Reason+":"+d.Detail) { + return 0, nil + } c.warn("stage labels: close-first original reopen refused by the write-back gate; hive-closed PR stays closed until the contributor_adopt policy allows the reopen or a person reopens it", gateArgs...) return 0, nil } diff --git a/src/pkg/github/automerge/automerge_adoption_close_first_test.go b/src/pkg/github/automerge/automerge_adoption_close_first_test.go index 310d708e56..1861c6674f 100644 --- a/src/pkg/github/automerge/automerge_adoption_close_first_test.go +++ b/src/pkg/github/automerge/automerge_adoption_close_first_test.go @@ -597,6 +597,12 @@ func TestAdoptionCloseFirstReopenPolicyRefusalWarns(t *testing.T) { if out := logs.String(); !strings.Contains(out, "level=WARN") || !strings.Contains(out, "hive-closed PR stays closed") || !strings.Contains(out, "writeback_reason="+writeback.ReasonOwnOnly) { t.Fatalf("policy refusal not warned: %q", out) } + logs.Reset() + h.clock.advance(adoptCheckInterval) + h.sweep() + if out := logs.String(); strings.Contains(out, "hive-closed PR stays closed") { + t.Fatalf("unchanged refusal warned again: %q", out) + } } func TestAdoptionCopyFailedMarkerIsSettled(t *testing.T) { From 4b4177cea75dddc89bcbe51630d654cdea8d9a36 Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 07:35:42 +0000 Subject: [PATCH 12/13] fix(github): deflake TestWebhookCIRefetchListsHeadOnceAndRecordsListing (#16730) refetchHeadCI declines to list check runs when the process-wide REST budget is critical or the shared pacing window is engaged. The test read both globals without isolating them, so state leaked from an earlier test in the package could make the flush a no-op (listings = 0). Isolate the REST accounting store and reset pacing for the test. Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/pkg/github/webhook_ci_evidence_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pkg/github/webhook_ci_evidence_test.go b/src/pkg/github/webhook_ci_evidence_test.go index acd2b946ee..d36229b62f 100644 --- a/src/pkg/github/webhook_ci_evidence_test.go +++ b/src/pkg/github/webhook_ci_evidence_test.go @@ -221,6 +221,12 @@ func TestWebhookCIRefetchListsHeadOnceAndRecordsListing(t *testing.T) { t.Cleanup(resetPRDetailCacheForTest(clock.Now, 0)) t.Cleanup(resetWebhookTrackerForTest(clock.Now)) t.Cleanup(ResetCIEvidenceForTest(clock.Now)) + // refetchHeadCI refuses to list while the process-wide REST budget is + // critical or the pacing window is engaged; isolate both from whatever + // earlier tests left behind. + resetRESTAccountingForTest(t, clock.now) + ResetRateLimitPacingForTest() + t.Cleanup(ResetRateLimitPacingForTest) listings := 0 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/repos/org/repo/commits/sha-9/check-runs" { From 6421cb6fc1f559eca64838c599983064abdb5fa0 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 02:45:39 -0500 Subject: [PATCH 13/13] Remove orphaned serve/log_tail.go after streamtail switch v6 moved newTail/equalLines into serve/log_tail.go while v5 switched the only caller (serve_follow.go) and its test to streamtail.Fresh. On the merged head both functions are unreferenced and golangci-lint reports them as unused. Delete the file. Hive-Fix-Attempt: 3/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/crux/serve/log_tail.go | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 src/crux/serve/log_tail.go diff --git a/src/crux/serve/log_tail.go b/src/crux/serve/log_tail.go deleted file mode 100644 index b7b6ea2785..0000000000 --- a/src/crux/serve/log_tail.go +++ /dev/null @@ -1,30 +0,0 @@ -package serve - -// newTail returns the lines of cur that were not already seen in prev, -// treating both as windows onto the same append-only buffer: the longest -// suffix of prev that is a prefix of cur is the overlap. It is the CLI's -// stream rule (crux/cli.newTail) applied server side. -func newTail(prev, cur []string) []string { - max := len(prev) - if len(cur) < max { - max = len(cur) - } - for k := max; k > 0; k-- { - if equalLines(prev[len(prev)-k:], cur[:k]) { - return cur[k:] - } - } - return cur -} - -func equalLines(a, b []string) bool { - if len(a) != len(b) { - return false - } - for i := range a { - if a[i] != b[i] { - return false - } - } - return true -}