diff --git a/changelog.d/fixed-wrong-base-non-release-line.md b/changelog.d/fixed-wrong-base-non-release-line.md new file mode 100644 index 0000000000..94d37f4c76 --- /dev/null +++ b/changelog.d/fixed-wrong-base-non-release-line.md @@ -0,0 +1 @@ +- A contributor task in a repository with no `vN` release branches (one on `main` / `testing` / `stable`) is no longer offered the `wrong_base` verdict, which could only ever park the issue at `stage/045-needs-decision`; the agent asks in the decision form instead. A `wrong_base` verdict that does park now keeps the agent's own reason: its one park note quotes it (sanitized and capped, never used as a branch), the generic needs-decision question is no longer posted beside it, and the log and verdict record carry it. The hub still re-dispatches only to a validated `vN` branch. diff --git a/src/docs/contributor-relay.md b/src/docs/contributor-relay.md index 44168dd4bf..92b6139265 100644 --- a/src/docs/contributor-relay.md +++ b/src/docs/contributor-relay.md @@ -885,7 +885,7 @@ Your relay works one issue at a time out of a single **persistent** checkout und So the assignment prompt names the branch each task's work belongs on, asks the agent to verify that remote branch after fetching, starts the work branch from it (`git checkout -b upstream/`), and opens the PR against it (`gh pr create --base `). A release-line prefix such as `[v6]` or an issue-body declaration such as `**Target: v6.**` wins over the hive build/default branch; the title wins if both declarations conflict. A server-validated `wrong_base` correction wins on the next offer. Without a declaration, Hive uses its own build branch only for `hivecommons/hive`; foreign repositories defer to their own contribution instructions and then their default branch. -If the named branch is absent, or the referenced code exists only on another release line, the agent reports `HIVE_VERDICT: wrong_base — ` instead of calling the issue already done. The relay carries that branch separately on `task_complete`; the hub accepts only a `vN` release line and verifies it through GitHub. A real branch is persisted as routing memory, receives only the ordinary short completion cooldown, and the issue is offered again with that branch in its prompt. A missing, malformed, or unverifiable branch is submitted to the central stage engine as a `Parked` fact, which derives `stage/045-needs-decision`, and gets one bounded note naming the proposed branch. No `hive/already-done` label or completed-close path runs. +If the named branch is absent, or the referenced code exists only on another release line, the agent reports `HIVE_VERDICT: wrong_base — ` instead of calling the issue already done. The prompt offers this outcome only when the task has a declared `vN` base: a repository whose branches are `main` / `testing` / `stable` has no release line to re-dispatch to, so there the agent follows the repository's own target rules and, if it cannot tell where the work belongs, asks with the `no_work_needed — decision: …` form. The relay carries that branch separately on `task_complete`; the hub accepts only a `vN` release line and verifies it through GitHub. A real branch is persisted as routing memory, receives only the ordinary short completion cooldown, and the issue is offered again with that branch in its prompt. A missing, malformed, or unverifiable branch is submitted to the central stage engine as a `Parked` fact, which derives `stage/045-needs-decision`, and gets one bounded note per task naming the proposed branch and quoting the agent's own reason (sanitized, capped, never used as a branch). That note is the park's question, so the generic needs-decision question is not posted beside it, and the recorded verdict reason carries the agent's words too. No `hive/already-done` label or completed-close path runs. Before this, the prompt mentioned a branch exactly once ("push your branch to your fork") and never said which one to target, so one branch-specific issue redirected every later PR of a session: on 2026-09-02 five consecutive PRs landed on `v5`, only the first correctly, and three of the rest were fixes for defects live on the deployed `v4` ([#5729](https://github.com/hivecommons/hive/issues/5729)). Nobody in the loop could see it — the agent had nothing to check against, the contributor saw PRs opening and merging normally, and a maintainer saw correctly-formed PRs on a plausible branch. @@ -1620,7 +1620,7 @@ Evidence, strongest first, and what each buys: | A `no_work_needed` verdict whose reason cites a settling PR or commit that GitHub confirms ([#7871](https://github.com/hivecommons/hive/issues/7871), [#8477](https://github.com/hivecommons/hive/issues/8477)) | hub, async after booking | `no_work_needed` completion plus a **verified** claim-ledger entry on the issue — the citation becomes a real claim, not prose. If the relay marks it `verdict_reason_kind: "already_done"` with `evidence: {"pr": 123}` (or old relay text conservatively matches "merged PR #123" / "already fixed"), the hub comments, applies `contribute_already_done_label` (default `hive/already-done`), and closes as completed when the PR is verified merged on the default branch. Human-filed bugs close by default unless `hive: needs-confirmation` or `issues.reporter_confirmation` opted into reporter verification. **An issue with an open sub-issue is the exception:** a parent is not done because a merged PR is cited for it, so the hub records no claim, applies neither `hive/likely-done` nor `contribute_already_done_label`, posts no comment and does not close it; it logs `parent has open sub-issues; not marking done` once, and the `no_work_needed` offer hold stays in force. The enumeration's sub-issue count decides when it shows an open one; otherwise the hub re-reads the issue from GitHub first, and a failed re-read also writes nothing. | | A `no_work_needed` verdict with no verifiable citation ([#3987](https://github.com/hivecommons/hive/issues/3987)) | hub | `no_work_needed` completion; offer-pool suppression until newer activity or the window ends. If it was marked already-done but cited nothing or verification failed, the issue gets a comment saying the contributor *reports* it may already be resolved with no verifiable PR or commit, no `contribute_already_done_label` is applied, the run is marked `already-done-unverified`, and the longer `contribute_already_done_hold_days` window is used. | | A `blocked` verdict — nothing in the repo can move until something outside it lands ([#7924](https://github.com/hivecommons/hive/issues/7924)) | hub + relay | `blocked` completion: the **full with-PR cooldown** at once (not the 4h ladder), a marked ledger row carrying the reason, no settle attempt from it. The relay, with the task credential, applies the repo's `blocked` label so the admission gate holds the issue until a human clears it. | -| A `wrong_base` verdict naming a `vN` branch that GitHub confirms exists ([#13146](https://github.com/hivecommons/hive/issues/13146)) | hub | Short cooldown plus durable routing memory; the issue remains offerable and its next prompt bases and targets the validated branch. No settlement scan, `hive/already-done`, or close path. A missing/unverifiable branch becomes a central-stage-engine `Parked` fact and a one-line `stage/045-needs-decision` note. | +| A `wrong_base` verdict naming a `vN` branch that GitHub confirms exists ([#13146](https://github.com/hivecommons/hive/issues/13146)) | hub | Short cooldown plus durable routing memory; the issue remains offerable and its next prompt bases and targets the validated branch. No settlement scan, `hive/already-done`, or close path. A missing/unverifiable branch becomes a central-stage-engine `Parked` fact and a one-line `stage/045-needs-decision` note quoting the agent's reason. Offered only to tasks with a declared `vN` base. | | A PR-less `complete` from a relay that said how it decided (`completion_signal` = `verdict` or `chrome_idle`; [#6723](https://github.com/hivecommons/hive/issues/6723), [#7862](https://github.com/hivecommons/hive/issues/7862)) | hub `isEvidenceLessCompletion` | **Evidence-less**: the flat `completedNoPRCooldownHours` cooldown only, no escalation, no `TasksCompleted++`. | | A PR-less `complete` with `completion_signal` = `unknown` (a relay predating [#5376](https://github.com/hivecommons/hive/issues/5376), or the headless path) | hub | Booked as a completion — the deliberate compatibility exception: the hub changes behaviour only for a relay that has told it how the task ended. Upgrading the relay closes it. | diff --git a/src/pkg/dashboard/contribute_task_prompt.go b/src/pkg/dashboard/contribute_task_prompt.go index 63c4379709..fd44121a85 100644 --- a/src/pkg/dashboard/contribute_task_prompt.go +++ b/src/pkg/dashboard/contribute_task_prompt.go @@ -574,6 +574,28 @@ func buildTaskPromptBodyWithHintsAndIssueRead(repoFull, issueRef, title, sourceH if g := strings.TrimSpace(guide); g != "" { guideHint = "\n\n" + g + "\n\n" } + + // hivecommons/hive#13146: absence on the assigned base is not evidence + // that the issue is already done, so a task with a declared release line + // gets a distinct outcome carrying the branch that holds the work. The hub + // re-dispatches only to a `vN` branch (normalizeWrongBaseTarget), so the + // outcome is offered only when this task has one. Without a declared base + // the agent already follows the repository's own target rules (baseHint); + // a repository on main/testing/stable could only ever get the verdict + // parked with nothing to act on (projectbluefin/utah#1272, + // projectbluefin/ghostscript-printer-app#127), so an agent unsure where + // the work belongs asks in the decision form below instead. + wrongBaseHint := "If you cannot tell which branch this work belongs on, do not call the " + + "issue already done and do not guess a branch: ask with the decision form below, " + + "naming the branch you would use and why. " + if strings.TrimSpace(baseBranch) != "" { + wrongBaseHint = "If the declared base branch does not exist after fetch, or the issue's " + + "referenced code exists only on another release branch, do not call the " + + "issue already done. Verify the correct branch exists, then print " + + "'HIVE_VERDICT: wrong_base — ' and stop. Hive validates " + + "that branch and re-offers the issue against it; if validation fails, Hive " + + "parks the issue at stage/045 with the named branch. " + } // #13059: companion checkouts, right after the primary checkout step // they sit beside. A target repo's tooling may resolve a registered // sibling location to $HIVE_WORKSPACE_DIR// and its @@ -648,15 +670,9 @@ func buildTaskPromptBodyWithHintsAndIssueRead(repoFull, issueRef, title, sourceH "is auto-labelled do-not-merge/work-in-progress and cannot merge. If a PR "+ "is already open as a draft, mark it ready for review. "+ "Use the GH_TOKEN env var for all gh commands (do NOT use 'unset GITHUB_TOKEN'). "+ - // hivecommons/hive#13146: absence on the assigned base is not - // evidence that the issue is already done. Give the relay a distinct - // outcome carrying the branch that actually contains the work. - "If the declared base branch does not exist after fetch, or the issue's "+ - "referenced code exists only on another release branch, do not call the "+ - "issue already done. Verify the correct branch exists, then print "+ - "'HIVE_VERDICT: wrong_base — ' and stop. Hive validates "+ - "that branch and re-offers the issue against it; if validation fails, Hive "+ - "parks the issue at stage/045 with the named branch. "+ + // hivecommons/hive#13146: the wrong_base outcome, offered only + // where it can succeed (wrongBaseHint above). + "%s"+ // #3987: the no_work_needed sentinel. The relay scrapes this exact // marker from the agent's output and reports it as the completion // verdict, so an issue whose remainder is maintainer-gated stops @@ -784,7 +800,7 @@ func buildTaskPromptBodyWithHintsAndIssueRead(repoFull, issueRef, title, sourceH "appear after your verdict, you may be asked once to address the "+ "ones that apply and print the HIVE_VERDICT line again — do so; that "+ "second line is expected, and it is final.", - repoFull, issueRef, title, sourceHint, checkoutHint, readIssue, baseHint, guideHint, pushHint, + repoFull, issueRef, title, sourceHint, checkoutHint, readIssue, baseHint, guideHint, pushHint, wrongBaseHint, ) } diff --git a/src/pkg/dashboard/contribute_wrong_base.go b/src/pkg/dashboard/contribute_wrong_base.go index 22acc1bf63..768659041e 100644 --- a/src/pkg/dashboard/contribute_wrong_base.go +++ b/src/pkg/dashboard/contribute_wrong_base.go @@ -11,9 +11,34 @@ import ( const ( wrongBaseValidationTimeout = 15 * time.Second - wrongBaseParkMarker = "" + wrongBaseParkMarkerPrefix = "" + } + return wrongBaseParkMarkerPrefix + " -->" +} + +// wrongBaseParkReason is the reason a parked wrong_base verdict is recorded +// and logged with: the hub's finding plus the agent's own words, which are +// the only thing a maintainer can act on. agentReason is already sanitized. +func wrongBaseParkReason(detail, agentReason string) string { + if agentReason == "" { + return detail + } + return detail + "; the agent said: " + agentReason +} + // normalizeWrongBaseTarget accepts the release-line vocabulary contributor // dispatch can route. Keeping this identical to declared issue targets prevents // a relay-supplied ref expression from becoming a git argument in a later prompt. @@ -35,8 +60,7 @@ func (h *ContributeWSHub) resolveWrongBaseVerdict(task *WSTaskAssign, verdict, p } target = normalizeWrongBaseTarget(proposed) if task == nil || task.Repo == "" || target == "" { - return completionVerdictNeedsDecision, target, - "wrong_base: no valid target release branch was supplied", true + return completionVerdictNeedsDecision, target, wrongBaseNoTargetReason, true } ctx, cancel := context.WithTimeout(context.Background(), wrongBaseValidationTimeout) @@ -64,42 +88,56 @@ func (h *ContributeWSHub) wrongBaseBranchExists(ctx context.Context, repo, branc return h.server.deps.GHClient.BranchExists(ctx, repo, branch) } -func wrongBaseParkComment(reporter, target, detail, label string) string { +// wrongBaseParkComment is the one note a parked wrong_base verdict posts; it +// is also the park's question, so the generic needs-decision question is not +// posted beside it. agentReason is the agent's own text, sanitized by the +// caller (no mentions, backticks, HTML comments or line breaks), quoted as +// untrusted text and never used as a branch. +func wrongBaseParkComment(taskID, reporter, target, detail, agentReason, label string) string { who := "a contributor's agent" if reporter = strings.TrimSpace(reporter); reporter != "" { who = "@" + reporter + "'s agent" } - branch := "no valid branch" + var line string if target != "" { - branch = "`" + target + "`" - } - return fmt.Sprintf("%s Hive could not re-dispatch %s wrong-base verdict to %s (%s), so `%s` remains until a maintainer corrects the target branch.", - wrongBaseParkMarker, who, branch, detail, label) + line = fmt.Sprintf("Hive could not re-dispatch %s wrong-base verdict to `%s` (%s), so `%s` remains until a maintainer corrects the target branch.", + who, target, detail, label) + } else { + line = fmt.Sprintf("Hive could not re-dispatch %s wrong-base verdict: it named no `vN` release branch, the only kind Hive re-dispatches to, so `%s` remains until a maintainer decides where this work belongs.", + who, label) + } + said := "The agent gave no reason." + if agentReason != "" { + said = "The agent said: \u201c" + agentReason + "\u201d" + } + return fmt.Sprintf("%s %s %s Reply `/hive decision ` to send the issue back with direction.", + wrongBaseParkMarker(taskID), line, said) } // parkWrongBaseIssue records the fallback required when the proposed branch is // absent or GitHub cannot validate it. Runs detached from the WebSocket loop. -func (h *ContributeWSHub) parkWrongBaseIssue(task *WSTaskAssign, reporter, target, detail string) { +func (h *ContributeWSHub) parkWrongBaseIssue(task *WSTaskAssign, taskID, reporter, target, detail, agentReason string) { if h == nil || task == nil || task.Kind != "issue" || task.Repo == "" || task.Number <= 0 || task.ExternalID != "" { return } ctx, cancel := context.WithTimeout(context.Background(), gateParkReleaseTimeout) defer cancel() - if err := h.parkWrongBase(ctx, task.Repo, task.Number, reporter, target, detail); err != nil { + body := wrongBaseParkComment(taskID, reporter, target, detail, agentReason, h.configuredNeedsDecisionLabel()) + if err := h.parkWrongBase(ctx, task.Repo, task.Number, wrongBaseParkMarker(taskID), body); err != nil { h.logger.Warn("[contribute-ws] wrong-base verdict: could not park invalid target", "repo", task.Repo, "number", task.Number, "target_branch", target, "error", err) } } -func (h *ContributeWSHub) parkWrongBase(ctx context.Context, repo string, number int, reporter, target, detail string) error { +func (h *ContributeWSHub) parkWrongBase(ctx context.Context, repo string, number int, marker, body string) error { if h.wrongBaseParker != nil { - return h.wrongBaseParker(ctx, repo, number, reporter, target, detail) + return h.wrongBaseParker(ctx, repo, number, marker, body) } if h.server == nil || h.server.deps == nil || h.server.deps.GHClient == nil { return ghpkg.ErrNoGitHubClient } client := h.server.deps.GHClient - posted, err := client.IssueCommentsContain(ctx, repo, number, wrongBaseParkMarker) + posted, err := client.IssueCommentsContain(ctx, repo, number, marker) if err != nil { return err } @@ -114,6 +152,5 @@ func (h *ContributeWSHub) parkWrongBase(ctx context.Context, repo string, number if posted { return nil } - return client.CreateIssueComment(ctx, repo, number, - wrongBaseParkComment(reporter, target, detail, label)) + return client.CreateIssueComment(ctx, repo, number, body) } diff --git a/src/pkg/dashboard/contribute_wrong_base_test.go b/src/pkg/dashboard/contribute_wrong_base_test.go index 3f24fd3550..5f8714b8ff 100644 --- a/src/pkg/dashboard/contribute_wrong_base_test.go +++ b/src/pkg/dashboard/contribute_wrong_base_test.go @@ -40,9 +40,14 @@ func TestWrongBaseVerdict_InvalidOrUnverifiableBranchParks(t *testing.T) { task := &WSTaskAssign{Kind: "issue", Repo: "hivecommons/hive", Number: 13146} verdict, target, reason, park := hub.resolveWrongBaseVerdict(task, completionVerdictWrongBase, "feature/x") - if verdict != completionVerdictNeedsDecision || target != "" || !park || !strings.Contains(reason, "no valid target") { + if verdict != completionVerdictNeedsDecision || target != "" || !park || reason != wrongBaseNoTargetReason { t.Fatalf("malformed target resolved = (%q, %q, %q, %v)", verdict, target, reason, park) } + // A repository on main/testing/stable has no release branch to supply + // (projectbluefin/utah#1272); the reason must not say one was missing. + if strings.Contains(reason, "release branch was supplied") { + t.Fatalf("no-target reason blames a missing release branch: %q", reason) + } hub.wrongBaseBranchChecker = func(context.Context, string, string) (bool, error) { return false, errors.New("rate limited") @@ -54,17 +59,85 @@ func TestWrongBaseVerdict_InvalidOrUnverifiableBranchParks(t *testing.T) { } func TestWrongBaseVerdict_ParkCommentIsOneLineAndNamesBranch(t *testing.T) { - comment := wrongBaseParkComment("alice", "v6", "target branch v6 does not exist", "stage/045-needs-decision") + comment := wrongBaseParkComment("ct-1", "alice", "v6", "target branch v6 does not exist", "", "stage/045-needs-decision") if strings.Contains(comment, "\n") { t.Fatalf("park comment must be one line: %q", comment) } - for _, want := range []string{wrongBaseParkMarker, "@alice", "`v6`", "`stage/045-needs-decision`"} { + for _, want := range []string{wrongBaseParkMarker("ct-1"), "@alice", "`v6`", "`stage/045-needs-decision`", "The agent gave no reason.", "/hive decision"} { if !strings.Contains(comment, want) { t.Errorf("park comment missing %q: %q", want, comment) } } } +// projectbluefin/utah#1272 and projectbluefin/ghostscript-printer-app#127: a +// wrong_base verdict whose target is not a vN branch parks with the agent's +// own reason quoted, never as a ref, and without the "release branch was +// supplied" phrase a main/testing/stable repository cannot act on. +func TestWrongBaseVerdict_ParkCommentQuotesAgentReason(t *testing.T) { + agent := sanitizeReportedReason("testing — utah's AGENTS.md says all PRs target `testing`; @someone knows") + for _, tc := range []struct { + name, target, detail string + }{ + {"non-vN branch named", "", wrongBaseNoTargetReason}, + {"vN that does not exist", "v9", "wrong_base: target branch v9 does not exist"}, + } { + t.Run(tc.name, func(t *testing.T) { + comment := wrongBaseParkComment("ct-utah-1272", "Karibhou", tc.target, tc.detail, agent, "stage/045-needs-decision") + if strings.Contains(comment, "\n") { + t.Fatalf("park comment must be one line: %q", comment) + } + for _, want := range []string{ + wrongBaseParkMarker("ct-utah-1272"), + "@Karibhou's agent", + "The agent said: \u201ctesting \u2014 utah's AGENTS.md says all PRs target testing;", + "/hive decision", + } { + if !strings.Contains(comment, want) { + t.Errorf("park comment missing %q: %q", want, comment) + } + } + for _, bad := range []string{"release branch was supplied", "@someone", "