diff --git a/bin/contributor-relay.js b/bin/contributor-relay.js index 5354057de4..7ead366557 100755 --- a/bin/contributor-relay.js +++ b/bin/contributor-relay.js @@ -1270,6 +1270,9 @@ const RELAY_CAPABILITIES = ['quota_preflight_v1', 'run-stage', 'fix_pr_interrupt // fix is DEFERRED and runs before the next `ready`. // A fix never replaces currentTask: the primary lease stays owned and renewed. const FIX_PR_KIND = 'fix-pr'; +// Every follow-up commit must be signed off or the PR bounces to no-dco +// (hivecommons/hive#14605). +const FIX_PR_SIGNOFF_REQUIREMENT = 'REQUIRED: every follow-up commit MUST carry a Signed-off-by trailer — commit with `git commit -s`, and run `git rebase --signoff` before pushing if any new commit lacks one.'; const FIX_PR_MAX_PARALLEL = Math.max(0, Math.min(16, Number(process.env.HIVE_MAX_PARALLEL_FIXES || 1) || 0)); const FIX_PR_DONE_MARKER = 'HIVE_FIX_PR_DONE'; const FIX_PR_FAILED_MARKER = 'HIVE_FIX_PR_FAILED'; @@ -4017,7 +4020,9 @@ function headlessProgressTick(task) { const WORKSPACE_DIR_VARIABLE = /\$\{?HIVE_WORKSPACE_DIR\}?/g; function resolveTaskPrompt(task) { const prompt = task.prompt || `Work on ${task.kind} ${task.repo}#${task.number}: ${task.title}`; - return prompt.replace(WORKSPACE_DIR_VARIABLE, TASK_WORKSPACE_DIR); + const resolved = prompt.replace(WORKSPACE_DIR_VARIABLE, TASK_WORKSPACE_DIR); + if (task.kind !== FIX_PR_KIND) return resolved; + return `${resolved}\n\n${FIX_PR_SIGNOFF_REQUIREMENT}`; } // installRepoToolchain runs bin/repo-toolchain.sh against the task's checkout diff --git a/bin/contributor-relay.test.js b/bin/contributor-relay.test.js index 9de87171dd..d281fda9ec 100644 --- a/bin/contributor-relay.test.js +++ b/bin/contributor-relay.test.js @@ -14243,6 +14243,16 @@ test('#7908 resolveTaskPrompt leaves a prompt without the variable untouched and } finally { teardown(relay); } }); +test('#14605 resolveTaskPrompt requires sign-off on fix-pr tasks only', () => { + const relay = loadRelay({}); + try { + const fix = relay.resolveTaskPrompt({ kind: 'fix-pr', prompt: 'fix it' }); + assert.ok(fix.startsWith('fix it'), 'original prompt is kept'); + assert.ok(fix.includes('git commit -s') && fix.includes('git rebase --signoff') && fix.includes('Signed-off-by')); + assert.ok(!relay.resolveTaskPrompt({ kind: 'issue', prompt: 'do it' }).includes('Signed-off-by')); + } finally { teardown(relay); } +}); + // --------------------------------------------------------------------------- // hivecommons/hive#7907 — the verdict is judged on a settled pane, not the // capture that discovered it. diff --git a/changelog.d/fixed-14605.md b/changelog.d/fixed-14605.md new file mode 100644 index 0000000000..26a9621405 --- /dev/null +++ b/changelog.d/fixed-14605.md @@ -0,0 +1 @@ +- Review-fix and relay fix-pr prompts now require Signed-off-by on every follow-up commit (#14605) diff --git a/src/pkg/review/dispatch.go b/src/pkg/review/dispatch.go index cfa87691eb..976e8a47c7 100644 --- a/src/pkg/review/dispatch.go +++ b/src/pkg/review/dispatch.go @@ -1365,6 +1365,7 @@ func BuildFixPrompt(pr PullRequest, agg Aggregate, attempt, maxAttempts int) str } fmt.Fprintf(&b, "Auto-fix attempt %d of %d. Stay narrowly scoped to the review findings below; push a new commit to the PR branch.\n\n", attempt, maxAttempts) fmt.Fprintf(&b, "When committing the fix, include this exact git trailer so rework metrics can count the attempt: Hive-Fix-Attempt: %d/%d\n\n", attempt, maxAttempts) + b.WriteString("REQUIRED: every follow-up commit MUST carry a Signed-off-by trailer — create it with `git commit -s`, and run `git rebase --signoff` before pushing if any new commit lacks one. An unsigned fix commit bounces the PR to no-dco.\n\n") if req := pr.HumanChangeRequest; req != nil && strings.TrimSpace(req.Body) != "" { b.WriteString(humanChangeRequestPromptSection(*req)) } diff --git a/src/pkg/review/dispatch_test.go b/src/pkg/review/dispatch_test.go index 16dbef67c3..a476929a7a 100644 --- a/src/pkg/review/dispatch_test.go +++ b/src/pkg/review/dispatch_test.go @@ -144,6 +144,9 @@ func TestBuildFixPromptAndCapExhaustion(t *testing.T) { if !strings.Contains(prompt, "nil panic") || !strings.Contains(prompt, "attempt 1") || !strings.Contains(prompt, "Hive-Fix-Attempt: 1/") || !strings.Contains(prompt, "acme/hive#7") { t.Fatalf("fix prompt missing expected context:\n%s", prompt) } + if !strings.Contains(prompt, "git commit -s") || !strings.Contains(prompt, "git rebase --signoff") || !strings.Contains(prompt, "Signed-off-by") { + t.Fatalf("fix prompt must require sign-off on follow-up commits:\n%s", prompt) + } state := DispatchState{} for i := 1; i <= escalation.MaxReEngagements; i++ { state.Fixes = append(state.Fixes, PendingFix{Repo: "acme/hive", Number: 7, HeadSHA: "old", Attempts: i})