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-wrong-base-non-release-line.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions src/docs/contributor-relay.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <your-branch> upstream/<base>`), and opens the PR against it (`gh pr create --base <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 — <correct-branch>` 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 — <correct-branch>` 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.

Expand Down Expand Up @@ -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. |

Expand Down
36 changes: 26 additions & 10 deletions src/pkg/dashboard/contribute_task_prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) != "" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gate is baseBranch != "", but the hub only re-dispatches to a vN branch (normalizeWrongBaseTarget). taskBaseBranchForIssue returns the hive's own hubBranch unchecked for hivecommons/hive, so a non-vN build branch would still be offered wrong_base and park. Consider isReleaseLine(strings.ToLower(strings.TrimSpace(baseBranch))) to match the comment and docs.

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 — <correct-branch>' 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/<org>/<sibling> and its
Expand Down Expand Up @@ -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 — <correct-branch>' 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
Expand Down Expand Up @@ -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,
)
}

Expand Down
69 changes: 53 additions & 16 deletions src/pkg/dashboard/contribute_wrong_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,34 @@ import (

const (
wrongBaseValidationTimeout = 15 * time.Second
wrongBaseParkMarker = "<!-- hive:wrong-base-park -->"
wrongBaseParkMarkerPrefix = "<!-- hive:wrong-base-park"
)

// wrongBaseNoTargetReason is the park reason when the verdict named no `vN`
// branch. It does not say "release branch was supplied": a repository on
// main/testing/stable has no release branch to supply (projectbluefin/utah#1272).
const wrongBaseNoTargetReason = "wrong_base: the agent named no `vN` release branch, the only kind Hive can re-dispatch to"

// wrongBaseParkMarker tags the park note for one task, so a re-delivered
// completion posts nothing twice while a later task's park still gets its own
// note with that agent's reason.
func wrongBaseParkMarker(taskID string) string {
if id := sanitizeParkTaskID(taskID); id != "" {
return wrongBaseParkMarkerPrefix + " task=" + id + " -->"
}
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.
Expand All @@ -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)
Expand Down Expand Up @@ -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 <your instructions>` 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
}
Expand All @@ -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)
}
Loading
Loading