Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-contributor-decision-needs-finding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Contributor-lane PRs no longer park at `stage/085-needs-decision` on a reviewer decision marker or bare `requires_human` while they are in CI/Review. The only early exit is a concrete security / trust finding (`review.IsSecuritySensitiveFinding`: reviewer high-risk marker, security perspective hold, security-class question, finding on a sensitive path — `sentinel.sensitive_paths` plus the new `security.sensitive_paths` — or insecure behaviour flagged), recorded as `decision_finding` and printed by the 085 comment and tracker as `the review found: …`. Everything else goes back to the clanker or is advisory and the PR moves on to the merge gate, where an untrusted author's PR parks at `stage/090-ready-for-human-merge` for the operator's merge — never auto-merged (#15640).
1 change: 1 addition & 0 deletions src/cmd/hive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11180,6 +11180,7 @@ func refreshReviewVerdicts(cfg *config.Config, logger *slog.Logger) {
MaxPerspectivesPerPR: cfg.Review.MaxPerspectivesPerPR,
Perspectives: reviewPerspectiveSet(cfg, logger),
SelfAuthoredDecisionPolicy: cfg.Review.EffectiveSelfAuthoredDecisionPolicy(),
SensitivePaths: cfg.Security.SensitivePaths,
ModelStamps: reviewModelStamps(logger),
ExpectedHeads: cfg.ExpectedReviewHeads(),
MissingHeads: reviewMissingHeads(),
Expand Down
1 change: 1 addition & 0 deletions src/cmd/hive/merge_eligibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ func contributorLaneVerdictFromArtifact(artifact review.Artifact, repo string, n
Verdict: string(match.Verdict),
DecisionRequested: match.DecisionRequested,
DecisionQuestion: match.DecisionQuestion,
DecisionFinding: match.DecisionFinding,
RedundantOf: match.RedundantOf,
HumanSummaries: append([]string(nil), match.HumanSummaries...),
HiveAuthoredKnown: match.HiveAuthoredKnown,
Expand Down
18 changes: 18 additions & 0 deletions src/docs/hive-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,24 @@ unattended (for example `mrbobbytables`):
A claim keeps the tier the contributor held when it was taken, so grant the
tier before the issue is leased.

**No decision during CI/Review; the operator has the last word on
untrusted merges.** A contributor PR is not parked at
`stage/085-needs-decision` on a reviewer decision marker alone. While it is
in CI/Review the hive runs CI and the review swarm to completion and the
row always names its mover; the only early exit is a concrete security /
trust finding (`review.IsSecuritySensitiveFinding`: high-risk marker,
security perspective hold, security-class question, finding on a sensitive
path — `sentinel.sensitive_paths` plus `security.sensitive_paths` — or
insecure behaviour flagged), recorded as `decision_finding` and printed as
`the review found: …`. Anything else goes back to the clanker or is
advisory and the PR keeps moving. At the merge gate a contributor the lane
cannot vouch for parks at `stage/090-ready-for-human-merge`
(`contributor-lane:claim-tier-untrusted`, `untrusted-author-role`, the
human-merge rule) and waits for the operator's merge — the hive never
auto-merges an untrusted author's PR, however green, approved and soaked.
See [review-swarm.md](review-swarm.md) ("Contributor and human-authored
PRs: no decision in CI/Review").

### Issue-author credit at merge time

Every merge the hive performs — the self-authored, trusted-author,
Expand Down
53 changes: 53 additions & 0 deletions src/docs/review-swarm.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,59 @@ decision marker parks the PR for a person. The reviewer template
issue/spec and PR body before asking, and to cite the answer
(`per #<issue>: …`) instead of raising a question the issue already settled.

**Contributor and human-authored PRs: no decision in CI/Review unless the
review found something fishy or insecure.** The owner's rules
([#15640](https://github.com/hivecommons/hive/issues/15640)), verbatim:

> there should be no decisions by a human while these are in ci/review —
> unless the review found something.
> unless you find something fishy and insecure happening at the pr in
> progress level, then we can let things go and then decide in merge
> queue, if needed.
> we dont want to create a log jam during pr in progress.
> i always have the last word when it comes to merge of untrusted.

So while a PR the hive did not author is in CI/Review, the hive runs CI and
the review swarm to completion on its own, and the stage always has an
active mover (CI, the swarm, the clanker fixing, the hive adopting). The
**only** early exit to `stage/085-needs-decision` is a concrete security /
trust finding — one predicate, `review.IsSecuritySensitiveFinding`
(`src/pkg/review/security_finding.go`):

- the reviewer's `<!-- hive-decision-risk: high -->` marker;
- the security perspective withholding approval (`requires_human`);
- a decision question in a security-class risk class — `security`,
`permissions-credentials`, `sensitive-paths` (workflows, CODEOWNERS,
branch protection, deploy, Dockerfiles, dependency manifests, …);
- an in-scope finding on a sensitive path: `sentinel.DefaultSensitivePaths`
plus the operator's extra globs in `security.sensitive_paths`;
- an in-scope finding, or the review summary, flagging insecure or
suspicious behaviour (injection, exfiltration, secrets, unpinned actions,
supply chain, …).

A sentinel alert (`contributor-lane:sentinel-blocked`), a workflow-path or
tests-removed lane rule and a reporter-trust hold are the lane-side
equivalents and park the PR the same way. The finding is recorded as
`decision_finding` and the 085 comment and tracker popover print it as
`the review found: …` next to the reviewer's question, so the operator is
told WHAT was found.

Everything else the review raises — ordinary nits and findings, a duplicate,
naming, scope, sequencing, licensing, a failing optional check, a conflict
— never asks a person during CI/Review: a finding goes back to the
clanker / adoption path as `changes_requested`; a bare question is
advisory, the aggregate is `approve`, recorded as
`no security finding — the PR keeps moving; a person has the last word at the merge gate; recorded as advisory: <question>`,
and the PR moves on. At the merge gate the untrusted-author invariant
holds: a contributor the lane cannot vouch for parks at
`stage/090-ready-for-human-merge` (`contributor-lane:claim-tier-untrusted`,
`untrusted-author-role`, the human-merge rule) and waits for the operator's
merge-now / queue-merge — the hive never auto-merges an untrusted author's
PR, green, approved and soaked or not. `self_authored_decision_policy:
escalate` restores the old park-on-every-marker behavior for these PRs too.
review. The same `self_authored_decision_policy: escalate` switch restores
the old park-on-every-marker behavior for these PRs too.

Two decision questions never reach the swarm or a person at all, because
the hive already owns the answer:

Expand Down
3 changes: 3 additions & 0 deletions src/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ type Config struct {
// escalation or codebase damage, from any author. Default on; see
// SentinelConfig.
Sentinel SentinelConfig `yaml:"sentinel,omitempty" json:"sentinel,omitempty"`
// Security holds the hive-wide security knobs that are not one agent's
// or one sweep's; see SecurityConfig.
Security SecurityConfig `yaml:"security,omitempty" json:"security,omitempty"`
// Evidence controls the review evidence bundles the review relay writes
// (hivecommons/hive#11060). Default on, unsigned; see EvidenceConfig.
Evidence EvidenceConfig `yaml:"evidence,omitempty" json:"evidence,omitempty"`
Expand Down
17 changes: 17 additions & 0 deletions src/pkg/config/security.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package config

// SecurityConfig is the hive-wide `security:` block.
//
// Owner rule (hivecommons/hive#15640): a contributor's PR runs CI and the
// review swarm hands-free; the only thing that may park it for a person
// during CI/Review is a concrete security / trust finding
// (review.IsSecuritySensitiveFinding). The finding predicate treats a
// review finding on a sensitive path as such a finding; the path set is
// sentinel.DefaultSensitivePaths plus the globs here.
type SecurityConfig struct {
// SensitivePaths are extra glob patterns (same syntax as
// sentinel.sensitive_paths: `deploy/**`, `internal/auth/**`,
// `**/Dockerfile`) that an untrusted author touching, with a review
// finding on them, parks the PR for a person during CI/Review.
SensitivePaths []string `yaml:"sensitive_paths,omitempty" json:"sensitive_paths,omitempty"`
}
1 change: 1 addition & 0 deletions src/pkg/config/testdata/agent_runtime_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@
"quality": {},
"intent": {},
"sentinel": {},
"security": {},
"evidence": {
"complexity": {}
},
Expand Down
1 change: 1 addition & 0 deletions src/pkg/dashboard/settings_parity_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ forgestate.freshness_bound_s # yaml-only until readers migrate (#13373)
forgestate.reconcile_interval_s # yaml-only until readers migrate (#13373)
forgestate.search_budget # yaml-only until readers migrate (#13373)
scanner.skip_issues_with_open_pr # open-PR dispatch guard (#14799); yaml-only
security.sensitive_paths[] # TODO #15640
self_experiments.scheduler.enabled # TODO #11854
self_experiments.scheduler.interval_s # TODO #11854
self_experiments.scheduler.mode # TODO #11854
Expand Down
27 changes: 27 additions & 0 deletions src/pkg/dashboard/stage_tracker_ci_review_mover_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package dashboard

import (
"testing"

"github.com/hivecommons/hive/pkg/stagelabels"
)

// Owner rule (hivecommons/hive#15640): "we dont want to create a log jam
// during pr in progress". Every CI/Review row names who is moving it — CI,
// the review swarm, the hive, or the author — never a maintainer and never
// nobody, whatever lane reason the record carries.
func TestStageTrackerCIReviewCaptionAlwaysNamesAMover(t *testing.T) {
stages := []stagelabels.Stage{stagelabels.ReviewPending, stagelabels.Reviewed, stagelabels.Fixing, stagelabels.NeedsAuthor, stagelabels.ReturnedToContributor, stagelabels.AdoptedByHive}
reasons := []string{"", "contributor-lane:no-verdict", "contributor-lane:claim-tier-untrusted", "check-pending", "check-failing:unit", "conflicting", "contributor-lane:changes-requested", "something-unmapped"}
for _, stage := range stages {
for _, reason := range reasons {
caption, actor := stageTrackerCaption(stage, reason, "odttlnt", "pr", false, stagelabels.Record{}, false, 0, "036bff04036bff04036bff04036bff04036bff04")
if caption == "" || actor == "" {
t.Errorf("%v %q: caption=%q actor=%q — a CI/Review row with no mover", stage, reason, caption, actor)
}
if actor == "maintainer" {
t.Errorf("%v %q: actor is the maintainer during CI/Review (%q)", stage, reason, caption)
}
}
}
}
3 changes: 3 additions & 0 deletions src/pkg/dashboard/stage_tracker_decision.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand Down Expand Up @@ -835,6 +835,9 @@
d.Blocker = "Neither the author nor the hive can make CI run for this fork PR."
case reviewerDeferred:
d.Blocker = "The hive will not merge until a person decides."
if verdict != nil && strings.TrimSpace(verdict.DecisionFinding) != "" {
d.Blocker = "The review found: " + strings.TrimSpace(verdict.DecisionFinding) + ". " + d.Blocker
}
}
if held && selfHold == nil {
if d.Blocker != "" {
Expand Down
30 changes: 30 additions & 0 deletions src/pkg/github/automerge/automerge_contributor_lane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"github.com/hivecommons/hive/pkg/intent"
"github.com/hivecommons/hive/pkg/review"
hreview "github.com/hivecommons/hive/pkg/review"
"github.com/hivecommons/hive/pkg/stageengine"
"github.com/hivecommons/hive/pkg/stageengine/prstage"
"github.com/hivecommons/hive/pkg/stagelabels"
)

Expand Down Expand Up @@ -2022,3 +2024,31 @@ func storedChangeRequest(t *testing.T, head string) *hreview.HumanChangeRequests
}
return store
}

// Owner invariant (hivecommons/hive#15640), verbatim: "i always have the
// last word when it comes to merge of untrusted". A green, approved,
// soaked PR from a contributor the lane cannot vouch for (self-registered
// newcomer, untrusted tier) is never auto-merged: the lane refuses with
// claim-tier-untrusted and the stage engine parks it at 090
// ready-for-human-merge — the merge gate, not an 085 decision in review.
func TestContributorLaneUntrustedGreenApprovedParksForHumanMerge(t *testing.T) {
fx := validContributorFixture()
fx.issueComments[0]["body"] = contributorClaimMarkerTier(contributorLaneTestAuthor, "contributor", contributorLaneTestHive, " tier=newcomer verified=false")
api := newContributorLaneAPI(t, &fx)
defer api.Close()
policy := defaultContributorLanePolicy()
clock := &contributorLaneClock{at: time.Date(2026, 10, 15, 13, 0, 0, 0, time.UTC)}
engine := newContributorLaneEngine(api.URL, policy, clock, Options{ContributorSoak: soakedTracker(clock)})

_, reason, err := engine.trySweepContributorLanePR(context.Background(), "widget", "acme", "widget", 7, policy)
if err != nil || reason != contributorLaneReasonClaimTier {
t.Fatalf("reason = %q err = %v, want %q", reason, err, contributorLaneReasonClaimTier)
}
if fx.merges != 0 {
t.Fatalf("untrusted author auto-merged (%d merges)", fx.merges)
}
v := stageengine.ClassifyStage(prstage.Observation{Lane: stageLaneContributor, Reason: reason, HeadSHA: "sha7", Detail: prstage.Detail{VerdictKnown: true, Verdict: approvedVerdict("acme/widget", 7, "sha7")}})
if v.Stage != stagelabels.ReadyForHumanMerge || !v.Human {
t.Fatalf("stage = %+v, want 090 ready-for-human-merge awaiting the operator", v)
}
}
1 change: 1 addition & 0 deletions src/pkg/github/automerge/automerge_stage_human.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func (c *Engine) humanEvidence(ctx context.Context, tracker *StageTracker, key s
Cause: cause,
CauseReason: decisionCauseFor(obs.Reason, workflowManual),
DecisionQuestion: strings.TrimSpace(contributorVerdict.DecisionQuestion),
DecisionFinding: strings.TrimSpace(contributorVerdict.DecisionFinding),
HumanSummaries: append([]string(nil), contributorVerdict.HumanSummaries...),
SelfAuthored: obs.Lane == stageLaneSelf,
AuthorKind: obs.AuthorKind,
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/github/automerge/automerge_stage_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ func (c *Engine) ApplyStageLabels(ctx context.Context) (StageLabelResult, error)
if obs.Detail.VerdictKnown {
rawVerdict := obs.Detail.Verdict
normalizedVerdict := normalizeContributorLaneVerdict(rawVerdict)
c.info("stage labels: reviewer verdict route", "repo", obs.Display, "pr", obs.Number, "head", obs.HeadSHA, "lane", obs.Lane, "raw_verdict", rawVerdict.Verdict, "normalized_verdict", normalizedVerdict.Verdict, "decision_requested", normalizedVerdict.DecisionRequested, "decision_answered", normalizedVerdict.DecisionAnswered && normalizedVerdict.DecisionAnsweredHead == obs.HeadSHA, "decision_by", normalizedVerdict.DecisionAnsweredBy, "decision_directive", normalizedVerdict.DecisionDirective, "stage", verdict.Stage.String(), "reason", obs.Reason)
c.info("stage labels: reviewer verdict route", "repo", obs.Display, "pr", obs.Number, "head", obs.HeadSHA, "lane", obs.Lane, "raw_verdict", rawVerdict.Verdict, "normalized_verdict", normalizedVerdict.Verdict, "decision_requested", normalizedVerdict.DecisionRequested, "decision_answered", normalizedVerdict.DecisionAnswered && normalizedVerdict.DecisionAnsweredHead == obs.HeadSHA, "decision_by", normalizedVerdict.DecisionAnsweredBy, "decision_directive", normalizedVerdict.DecisionDirective, "decision_finding", normalizedVerdict.DecisionFinding, "stage", verdict.Stage.String(), "reason", obs.Reason)
}
add, remove := stagelabels.Plan(obs.Labels, want)
if len(add)+len(remove) > 0 {
Expand Down
Loading
Loading