Skip to content

πŸ› stage: a recorded /hive decision answers the head's requires_human verdict (no more 070↔085 flap) - #14759

Merged
hivecommons-hive[bot] merged 3 commits into
v5from
fix/decision-answered-verdict
Oct 28, 2026
Merged

hivecommons-hive[bot] merged 3 commits into
v5from
fix/decision-answered-verdict

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Refs #14679 β€” follow-up to #14684.

Problem: a flap, not a stall

hive#14628 (head 3b4a2b5, owner decision 18:25Z) moved 085β†’070 and back six times (18:45/19:04, 19:47 manual/20:00, 21:33/21:34). Pod logs showed stage labels: reviewer verdict route … stage=085-needs-decision reason=contributor-lane:decision-requested for the PR every ~90 s regardless of the current label.

Root cause: the stage pass classifies from the persisted reviewer verdict (requires_human + decision_requested) on the head. #14684 made the lanes note the owner's answer into the tracker detail, but the tracker's details are cleared on every drain and a lane that skips early (the contributor lane on an app-authored PR, a lane stopped at CI) never notes anything β€” so the next tick re-derived 085 from the unanswered verdict and undid whoever had moved it to 070 (unpark reply, fix planner, a maintainer by hand).

Fix

The recorded decision is already a durable, head-scoped artifact: review-human-change-requests.json (actor, head sha, recorded_at, kind, verbatim body), written at the moment the unpark reply is posted (record-before-reply). review-verdicts.json is regenerated from perspective reports by Collect, so a field there would be wiped; the decision store is the right home. This PR makes the verdict route consult it:

  • prstage.ReviewVerdict gains DecisionAnswered / DecisionAnsweredBy / DecisionAnsweredHead / DecisionDirective (approve | changes_requested) + WithDecisionAnswer.
  • review.DecisionAnswerFor(store, repo, pr, head) + HumanChangeRequest.Directive().
  • automerge: contributorLaneVerdictFor folds the store answer into the verdict (withRecordedDecision), and ApplyStageLabels calls foldRecordedDecision(list) on every drained observation before resolveStage β€” so the answer is seen on every tick, after restart, and independent of lane order.
  • stageengine: NormalizeStageDetail folds an answered verdict into HumanChangeRequester/HumanApprover for the head; HumanChangeRequestStage reports reason contributor-lane:decision-answered when the verdict asked for a person; RequiresHumanStage/TrustedHumanChangeRequested normalize first; ReviewFacts round-trips DecisionAnswered/DecisionDirective so the derive path (startup reconcile, dashboard) agrees; the PRDecided sink carries the answer too.
  • Verdict-route log line adds decision_answered, decision_by, decision_directive; nudge text explains the new reason; docs table row added.
situation tick result
decision with instructions on head H, any lane reason 070-fixing, reason contributor-lane:decision-answered
manual stage/070 while the decision stands kept (Plan is a no-op)
bare /hive decision approve on H hold cleared like a trusted Approve; lane proceeds
new head Hβ€² with a fresh requires_human 085-needs-decision again (answer is head-scoped)
answer recorded for H, PR now at Hβ€² ignored

Idempotency: the "Decision recorded" reply is posted once per (head, command comment id) β€” new candidates only; reconcileAnsweredPRDecision re-records silently (covered by TestSweepIssueUnparkCommandsReconcilesAnsweredDecisionAfterRestart). The fix kick prompt quotes every line of the decision verbatim (humanChangeRequestPromptSection; new test).

Tests (no time.Sleep)

  • stageengine: TestClassifyStageDecisionAnsweredVerdictNeverParks (tickβ†’070, lane's own decision-requested reasonβ†’070, manual 070 stands, approveβ†’merge path, new headβ†’085, stale answerβ†’085; each also via FactsFromPRObservations/ObservationsFromPRFacts), TestReviewFactsRoundTripDecisionAnswer.
  • automerge: TestFoldRecordedDecisionAnswersVerdictRoute, TestContributorLaneVerdictForCarriesRecordedDecision.
  • review: TestHumanChangeRequestPromptSectionCarriesEveryDecisionLine (+ DecisionAnswerFor).

Not run locally per AGENTS.md; CI is the verdict.

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 28, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kellyaa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 28, 2026
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#14787 πŸ› dco: re-home unsigned commits on adopted PRs so the gate can clear same files src/docs/labels-and-control-signals.md
src/pkg/github/automerge/automerge_stage_labels.go
src/pkg/stageengine/prstage/types.go

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson is auto-promoted for contributor-lane merging on this PR: the last 5 merged PRs by this author in this hive's repositories have no revert or sentinel-alert evidence. CI, reviewer verdict, diff fences, soak, holds and branch protection still apply.

@hivecommons-hive hivecommons-hive Bot added author/human A person pushed this PR themselves dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Failing checks:

  • build-and-test

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

@clubanderson
clubanderson force-pushed the fix/decision-answered-verdict branch from 6a26da9 to 001439e Compare October 28, 2026 00:43
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act labels Oct 28, 2026
@hivecommons-hive

hivecommons-hive Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Supersession sweep found that this PR's claimed issue is already closed by another merged PR.

  • Claimed issue: hive#14679
  • Closing PR: #14684

Decision needed (@hivecommons): #14684 already merged and closed the claimed issue, but this PR touches files the merged PR did not. Recommended: keep open until the extra changes are reviewed, or close as superseded if they are not wanted. Another option: merge anyway.

Files the merged PR did not touch: changelog.d/fixed-decision-answered-verdict.md, src/docs/labels-and-control-signals.md, src/pkg/github/automerge/automerge_contributor_lane.go, src/pkg/github/automerge/automerge_contributor_nudge.go, src/pkg/github/automerge/automerge_decision_answered_test.go and 1 more.

This comment is edited in place by the supersession sweep; it is not duplicated.

@hivecommons-hive hivecommons-hive Bot added stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Failing checks:

  • coverage

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

@hivecommons-hive hivecommons-hive Bot left a comment

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.

Mechanism reads correct to me; the one thing standing in the way is the coverage gate, and it is this diff's doing.

Verified. review.DecisionAnswerFor relies on HumanChangeRequests.For (src/pkg/review/human_change_request.go:187-208), which filters on item.HeadSHA == head and returns the newest RecordedAt β€” so a decision on head H never answers head H2, which is the invariant the whole change depends on. DecisionAnswered() (derive_pr_classify.go) is additionally gated on VerdictNeedsHuman(d), so a bare /hive decision approve on a head whose verdict never asked for a person does not get relabelled as "decision-answered". foldRecordedDecision skips observations already stamped for the same head, so the fold is idempotent across ticks. ObservationsFromPRFacts ↔ ReviewFactsFrom round-trip is consistent: both sides key the answer on head, and NormalizeStageDetail back-fills HumanChangeRequester/HumanApprover from the answer before the facts are read, so by is never empty on the way back in. go build of pkg/review, pkg/stageengine/..., pkg/github/automerge at 001439e is clean (I can't run go test from this host).

Low β€” coverage gate red because of this diff. The coverage job on 001439e (run 40610624806) fails with COVERAGE GATE FAILED: stageengine/prstage: 75.0% (floor 90%). The gate measures each package without -coverpkg, and the new ReviewVerdict.WithDecisionAnswer (src/pkg/stageengine/prstage/types.go:208-220) is only exercised from stageengine and automerge tests, so none of its four branches count toward prstage. A small prstage table test β€” empty by/head returns v unchanged; "approve" β†’ DecisionDirectiveApprove; anything else (including "" and " changes_requested ") β†’ DecisionDirectiveChanges; existing fields preserved β€” should clear it and is worth having anyway since that defaulting is the only place the directive string is canonicalised.

Docs: labels-and-control-signals.md gains the contributor-lane:decision-answered reason alongside the fixing reasons; matches stageFixingReasons.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

…'s requires_human verdict

The stage-label reconciler re-derived 085-needs-decision from the persisted
decision-requested verdict on every tick because nothing told the verdict
route that the owner's /hive decision had answered it; whoever moved the PR
to 070 (unpark reply, fix planner, a maintainer by hand) was undone ~90s
later (hive#14628 flapped 070<->085 six times).

The recorded decision (review-human-change-requests.json, head-scoped,
actor, timestamp, kind) is now folded into the reviewer verdict for that
head as DecisionAnswered/DecisionAnsweredBy/DecisionAnsweredHead/
DecisionDirective, both in the lanes' verdict lookup and in the stage pass
before classification, so a lane that skipped early can no longer leave the
question looking open. Instructions derive 070 with reason
contributor-lane:decision-answered; a bare approve clears the hold like a
trusted Approve review; a new head's fresh requires_human verdict carries no
answer and parks again. ReviewFacts round-trips the answer for the derive
path and the verdict-route log names decision_answered/by/directive.

Refs #14679

Signed-off-by: Andy Anderson <andy@clubanderson.com>
Signed-off-by: Andy Anderson <andy@clubanderson.com>
…coverage floor

Signed-off-by: Andy Anderson <andy@clubanderson.com>
@clubanderson
clubanderson force-pushed the fix/decision-answered-verdict branch from 001439e to 6b7a76e Compare October 28, 2026 01:19
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act labels Oct 28, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

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.

Reviewed β€” no findings from this perspective.

β€” hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit c4a7e6f into v5 Oct 28, 2026
76 of 79 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/decision-answered-verdict branch October 28, 2026 01:54

@hivecommons-hive hivecommons-hive Bot left a comment

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.

Reviewed β€” no findings from this perspective.

β€” hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#147596b7a76e` sha256:e36448794ba8aa32ab20283b9a575ada8368cc2e4a41832deb2d567929137fe5 β€” download from the dashboard or `hivectl review evidence #14759`.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 6b7a76e.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive hivecommons-hive Bot left a comment

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.

Looks correct to me. Read the three places the answer now enters and they agree on head scoping:

  • automerge_contributor_lane.go:1134-1150 folds review.DecisionAnswerFor into the lane verdict; DecisionAnswerFor β†’ HumanChangeRequests.For (human_change_request.go:204-225) is exact-head, newest-wins, so a new push draws no answer and asks again, as the doc row says.
  • automerge_stage_labels.go:475-490 foldRecordedDecision runs before resolveStage(list) for every item, which covers the lane-skipped-early case that produced the 070↔085 flap.
  • derive_pr_classify.go HumanChangeRequestStage keeps owned rank and only swaps the reason to contributor-lane:decision-answered when VerdictNeedsHuman held; stageFixingReasons carries the new reason, so nudge/classification stay consistent.

The facts_sink.go approve branch is reached only through pr_unpark_decision.go:298 (markerAuthorTrusted), so a bare approve setting HumanApprover is still trust-gated.

One nit, docs only: the PRDecided doc comment (facts_sink.go:208-213) still says "A bare approval only lifts the park direction … the deriver abstains here", which the new else if branch no longer does β€” it now records HumanApprover + DecisionDirectiveApprove. Worth a one-line update so the comment matches.

go build ./pkg/stageengine/... ./pkg/review/... ./pkg/github/automerge/... passes at 6b7a76e.

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/human A person pushed this PR themselves dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant