From ad7828e9a3a505ae47eed6b285c61e6d21fcda98 Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Sat, 7 Nov 2026 17:58:14 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fix(ci):=20re-validate=20pol?= =?UTF-8?q?icy=20checks=20before=20replaying=20a=20native-queue-policy=20v?= =?UTF-8?q?erdict=20(#16988)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(ci): re-validate policy checks before replaying a native-queue-policy verdict Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> * fix(ci): fall through to the full wait when a replayed policy provider is pending replayLastVerdict re-validates POLICY_CHECKS before replaying a prior success, but assertEvidence throws PendingEvidence for a missing or still-running provider and the workflow's replay step only tolerates transient API errors. A cosmetic label flip during a provider re-run therefore failed native-queue-policy outright with no retry. Catch PendingEvidence and return null so the caller runs the normal polling wait; add queued/in-progress/missing provider tests. Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: ci-maintainer <280983584+hivecommons-hive[bot]@users.noreply.github.com> * fix(ci): fall through on DCO UNKNOWN during replay; refresh replay docs Address review findings on #16988: - replayLastVerdict now returns null for ProviderUnavailable too, so the full wait re-raises it once and renders the runbook job summary instead of a bare setFailed from the label-flip step. - Re-flow the replayLastVerdict doc comment to ~80 columns. - native-merge-queue.md: replay re-validates the five policy checks on the head; red fails, pending/missing/UNKNOWN falls through. - Test: UNKNOWN DCO on replay falls through. Hive-Fix-Attempt: 2/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: ci-maintainer <280983584+hivecommons-hive[bot]@users.noreply.github.com> --------- Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Signed-off-by: ci-maintainer <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit eac7f886d692fe35799d67a64d8c6467900d4bea) Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .github/scripts/native-queue-policy.cjs | 23 +++++++++-- .github/scripts/native-queue-policy.test.cjs | 40 +++++++++++++++++++- src/docs/native-merge-queue.md | 15 +++++--- 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/.github/scripts/native-queue-policy.cjs b/.github/scripts/native-queue-policy.cjs index 5baeb710e0..48b4bc15a9 100644 --- a/.github/scripts/native-queue-policy.cjs +++ b/.github/scripts/native-queue-policy.cjs @@ -237,10 +237,12 @@ function isCosmeticLabelFlip({ eventName, payload }) { // A cosmetic flip skips the evidence wait but must not mint a fresh passing // required check: replay the latest completed `success` run of this check on // the head (rejecting one not from this workflow) and still read live PR -// eligibility. Returns null when there is nothing to replay — no completed -// run, or the latest one did not succeed (a failed, cancelled or timed-out -// wait) — so the caller falls through to the full evidence wait instead of -// pinning that earlier verdict onto every later stage-label flip. +// eligibility and the POLICY_CHECKS evidence. Returns null when there is +// nothing to replay — no completed run, or the latest one did not succeed (a +// failed, cancelled or timed-out wait), or a policy provider is missing, +// still running or reporting UNKNOWN — so the caller falls through to the +// full evidence wait instead of pinning that earlier verdict onto every later +// stage-label flip. async function replayLastVerdict({ github, context, currentCheckRunId }) { const repo = context.repo; const event = context.payload.pull_request; @@ -259,6 +261,19 @@ async function replayLastVerdict({ github, context, currentCheckRunId }) { // a run of this workflow file on this event may be replayed. await assertActionsProvenance(github, repo, pr.number, pr.head.sha, prior, POLICY_CHECK_SOURCE, new Map()); if (prior.conclusion !== 'success') return null; + // The prior success is only valid while the providers it validated are + // still green: one re-run red on this head must not be papered over. A + // provider that is missing or still running is not a verdict either way; + // fall through so the caller runs the full polling wait instead of failing. + // A DCO enumeration UNKNOWN also falls through: the full wait re-raises it + // once and renders the runbook job summary, so operators see the same + // surface whichever event fired. + try { + await assertEvidence(github, repo, pr.number, pr.head.sha, POLICY_CHECKS); + } catch (error) { + if (error instanceof PendingEvidence || error instanceof ProviderUnavailable) return null; + throw error; + } return `PR #${pr.number}: replayed ${POLICY_CHECK_NAME} run ${prior.id} (success) on ${pr.head.sha}`; } diff --git a/.github/scripts/native-queue-policy.test.cjs b/.github/scripts/native-queue-policy.test.cjs index 7a08dfec2f..c3d3e50f48 100644 --- a/.github/scripts/native-queue-policy.test.cjs +++ b/.github/scripts/native-queue-policy.test.cjs @@ -409,11 +409,16 @@ function replayFixture(priorRuns, labels = [], workflowOverride = {}) { check_suite: { id: 5000 + r.id }, details_url: `https://github.com/acme/widget/actions/runs/${3000 + r.id}/job/1`, ...r, })); - f.github.rest.actions.getWorkflowRun = async ({ run_id: id }) => ({ data: { + const baseGetWorkflowRun = f.github.rest.actions.getWorkflowRun; + const basePaginate = f.github.paginate; + f.github.rest.actions.getWorkflowRun = async ({ run_id: id }) => (id < 3000 ? baseGetWorkflowRun({ run_id: id }) : { data: { id, check_suite_id: id + 2000, path: '.github/workflows/native-queue-policy.yml', event: 'pull_request_target', head_sha: head, ...workflowOverride, } }); f.github.paginate = async (method, args) => { + // Policy provider evidence comes from the base fixture (all green). + if (method === 'jobs' && args.run_id < 3000) return basePaginate(method, args); + if (method === 'checks' && !args.check_name) return basePaginate(method, args); if (method === 'jobs') { const run = runs.find(r => 3000 + r.id === args.run_id); if (!run) return []; @@ -440,6 +445,39 @@ test('cosmetic flip replays the latest completed success on the same head', asyn assert.equal(f.state.listed[0].ref, sha(11)); }); +test('cosmetic flip does not replay a success when a policy provider re-ran red on the head', async () => { + for (const name of Object.keys(POLICY_CHECKS)) { + const f = replayFixture([{ id: 7, status: 'completed', conclusion: 'success' }]); + f.state.runs.get(sha(11)).find(r => r.name === name).conclusion = 'failure'; + await assert.rejects(replayLastVerdict(f), new RegExp(`${name}: failure`)); + } +}); + +test('cosmetic flip falls through to the full wait while a policy provider is re-running or missing', async () => { + // PendingEvidence is not a verdict: returning null sends the caller to the + // polling wait instead of failing the check with no retry. + for (const name of Object.keys(POLICY_CHECKS)) { + for (const change of [{ status: 'queued', conclusion: null }, { status: 'in_progress', conclusion: null }]) { + const f = replayFixture([{ id: 7, status: 'completed', conclusion: 'success' }]); + Object.assign(f.state.runs.get(sha(11)).find(r => r.name === name), change); + assert.equal(await replayLastVerdict(f), null); + } + const f = replayFixture([{ id: 7, status: 'completed', conclusion: 'success' }]); + const runs = f.state.runs.get(sha(11)); + runs.splice(runs.findIndex(r => r.name === name), 1); + assert.equal(await replayLastVerdict(f), null); + } +}); + +test('cosmetic flip falls through to the full wait when the DCO provider reports UNKNOWN', async () => { + // The full wait re-raises ProviderUnavailable once and renders the runbook + // job summary; failing here would skip that operator-facing surface. + const f = replayFixture([{ id: 7, status: 'completed', conclusion: 'success' }]); + Object.assign(f.state.runs.get(sha(11)).find(r => r.name === 'DCO'), + { conclusion: 'failure', output: { summary: unavailableSummary } }); + assert.equal(await replayLastVerdict(f), null); +}); + test('cosmetic flip has nothing to replay without a prior success and falls through', async () => { // A failed, cancelled (timed-out) or absent prior run must not be pinned // onto every later stage-label flip: null sends the caller to the full wait. diff --git a/src/docs/native-merge-queue.md b/src/docs/native-merge-queue.md index ebd97271be..be526e74c3 100644 --- a/src/docs/native-merge-queue.md +++ b/src/docs/native-merge-queue.md @@ -220,13 +220,16 @@ metadata, not a fabricated last-member PR event. in-progress); the queued run re-reads mutable PR state after the prior run finishes, preserving fail-closed semantics. Labels the policy never reads (`size/*`, `dco-signoff`, stage labels, ...) skip the wait: the job replays - the latest completed `native-queue-policy` `success` on the same head and - still checks the live PR for holds, draft and head moves. When there is no + the latest completed `native-queue-policy` `success` on the same head, + still checks the live PR for holds, draft and head moves, and re-validates + the five policy checks on that head — a provider re-run red since the + original verdict fails the job instead of being replayed. When there is no prior success to replay (never evaluated, or the last wait failed or timed - out) or GitHub returns a 5xx, the job falls through to the full wait so a - stale red verdict is never pinned onto later cosmetic flips. `hold`, - `needs-human`, `release-in-progress` and `do-not-merge*` flips always get - the full wait. + out), a policy provider is still pending or missing on the head, the DCO + provider reports UNKNOWN, or GitHub returns a 5xx, the job falls through to + the full wait so a stale verdict is never pinned onto later cosmetic flips. + `hold`, `needs-human`, `release-in-progress` and `do-not-merge*` flips + always get the full wait. - On a group it executes the event's trusted `base_sha` validator. It reads the live queue prefix ending at the event's exact synthetic head, verifies contiguous membership and the base/head commit chain, and checks From 6b390aa9f0b42ccf6b617a795546d6fcfbf1259b Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Sat, 7 Nov 2026 19:56:37 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20fix(ci):=20native-queue-poli?= =?UTF-8?q?cy=20accepts=20prow=20dco=20for=20v5-reachable=20sync/v5-to-v6?= =?UTF-8?q?=20forward-merges=20(#17050)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> (cherry picked from commit bde11aa2c319897f28b7b7a91c5ae73cf9f2b16d) Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .github/scripts/native-queue-policy.cjs | 103 ++++++++++++++++-- .github/scripts/native-queue-policy.test.cjs | 95 +++++++++++++++- src/docs/native-merge-queue.md | 15 ++- .../dco-provider-unavailable.md | 4 + 4 files changed, 204 insertions(+), 13 deletions(-) diff --git a/.github/scripts/native-queue-policy.cjs b/.github/scripts/native-queue-policy.cjs index 48b4bc15a9..a54bcab393 100644 --- a/.github/scripts/native-queue-policy.cjs +++ b/.github/scripts/native-queue-policy.cjs @@ -23,6 +23,17 @@ const BLOCKED_LABEL = /^(hold|needs-human|release-in-progress|do-not-merge(?:\/. const MAX_QUEUE_PAGES = 10; const POLICY_CHECK_NAME = 'native-queue-policy'; const POLICY_CHECK_SOURCE = ['native-queue-policy.yml', ['pull_request_target']]; +// Decision B on #17030: a v5→v6 forward-merge opened by v6-topup.yml carries +// commits that already passed v5's DCO gate, and probot DCO cannot be repaired +// PR-side. Only that exact shape may substitute prow's `dco` status. +const FORWARD_MERGE = { + head: 'sync/v5-to-v6', base: 'v6', source: 'v5', + author: { login: 'github-actions[bot]', id: 41898282, type: 'Bot' }, +}; +const PROW = { login: 'kubestellar-prow[bot]', id: 208851060, context: 'dco' }; +// REST pull-request commit listing stops at 250; a longer list is unverifiable. +const MAX_PR_COMMITS = 250; +const PROBOT_DCO_PATH = 'DCO path: probot DCO (App 1861)'; const closedNoop = (pr) => `PR #${pr.number} is closed; nothing to evaluate`; @@ -148,15 +159,83 @@ async function assertActionsProvenance(github, repo, number, head, run, source, } } -async function assertEvidence(github, repo, number, head, checks) { +async function reachableFrom(github, repo, branch, commit) { + const { data } = await github.rest.repos.compareCommitsWithBasehead({ + ...repo, basehead: `${branch}...${commit}`, + }); + return ['behind', 'identical'].includes(data.status); +} + +// Returns null when the PR is not the top-up shape at all, otherwise whether +// the narrow prow path applies and why. Any doubt keeps probot DCO required. +async function forwardMergeDCOPath(github, repo, pr, head) { + const author = FORWARD_MERGE.author; + if (pr?.head?.ref !== FORWARD_MERGE.head || pr.base?.ref !== FORWARD_MERGE.base || + pr.head.repo?.full_name !== `${repo.owner}/${repo.repo}` || + pr.user?.login !== author.login || pr.user.id !== author.id || pr.user.type !== author.type) { + return null; + } + const commits = await github.paginate(github.rest.pulls.listCommits, { + ...repo, pull_number: pr.number, per_page: 100, + }); + const fallback = why => ({ prow: false, path: `${PROBOT_DCO_PATH}; ${FORWARD_MERGE.head} fallback: ${why}` }); + if (commits.length === 0 || commits.length >= MAX_PR_COMMITS) { + return fallback(`commit list unverifiable (${commits.length} commits)`); + } + for (const commit of commits) { + if (!SHA.test(commit.sha)) return fallback('malformed commit list'); + // The tip is v6-topup.yml's own `--no-ff` merge of origin/v5 onto v6, so it + // is never on v5 itself: its parents must be v6 and v5 history exactly. + if (commit.sha === head) { + const [ours, theirs] = (commit.parents || []).map(p => p.sha); + if (commit.parents?.length !== 2 || !SHA.test(ours) || !SHA.test(theirs) || + !await reachableFrom(github, repo, FORWARD_MERGE.base, ours) || + !await reachableFrom(github, repo, FORWARD_MERGE.source, theirs)) { + return fallback(`head ${head} is not a merge of ${FORWARD_MERGE.source} into ${FORWARD_MERGE.base}`); + } + } else if (!await reachableFrom(github, repo, FORWARD_MERGE.source, commit.sha)) { + return fallback(`${commit.sha} is not reachable from ${FORWARD_MERGE.source}`); + } + } + if (!commits.some(c => c.sha === head)) return fallback(`head ${head} is not in the commit list`); + return { + prow: true, + path: `DCO path: prow ${PROW.context} for ${FORWARD_MERGE.source}-reachable ${FORWARD_MERGE.head} forward-merge (#17030)`, + }; +} + +async function assertProwDCO(github, repo, head) { + const statuses = await github.paginate(github.rest.repos.listCommitStatusesForRef, { + ...repo, ref: head, per_page: 100, + }); + // Any workflow token can post a `dco` status; only prow's own is evidence. + const status = statuses + .filter(s => s.context === PROW.context && s.creator?.login === PROW.login && s.creator.id === PROW.id) + .sort((a, b) => b.id - a.id)[0]; + if (!status) throw new PendingEvidence(`Missing prow ${PROW.context} on ${head}`); + if (status.state === 'pending') throw new PendingEvidence(`prow ${PROW.context} is pending`); + if (status.state !== 'success') throw new Error(`prow ${PROW.context}: ${status.state}`); +} + +async function assertEvidence(github, repo, number, head, checks, pr) { + const dco = Object.hasOwn(checks, 'DCO') ? await forwardMergeDCOPath(github, repo, pr, head) : null; + const required = { ...checks }; + if (dco?.prow) delete required.DCO; const runs = await github.paginate(github.rest.checks.listForRef, { ...repo, ref: head, per_page: 100, filter: 'latest', }); const workflows = new Map(); - for (const { run, source } of evidenceForHead(runs, head, checks)) { - if (!source) continue; // Probot DCO is deliberately not impersonated. - await assertActionsProvenance(github, repo, number, head, run, source, workflows); + try { + for (const { run, source } of evidenceForHead(runs, head, required)) { + if (!source) continue; // Probot DCO is deliberately not impersonated. + await assertActionsProvenance(github, repo, number, head, run, source, workflows); + } + if (dco?.prow) await assertProwDCO(github, repo, head); + } catch (error) { + if (dco && !(error instanceof ProviderUnavailable)) error.message += ` [${dco.path}]`; + throw error; } + return dco?.path || PROBOT_DCO_PATH; } async function assertReviews(github, repo, number, head) { @@ -268,13 +347,14 @@ async function replayLastVerdict({ github, context, currentCheckRunId }) { // A DCO enumeration UNKNOWN also falls through: the full wait re-raises it // once and renders the runbook job summary, so operators see the same // surface whichever event fired. + let path; try { - await assertEvidence(github, repo, pr.number, pr.head.sha, POLICY_CHECKS); + path = await assertEvidence(github, repo, pr.number, pr.head.sha, POLICY_CHECKS, pr); } catch (error) { if (error instanceof PendingEvidence || error instanceof ProviderUnavailable) return null; throw error; } - return `PR #${pr.number}: replayed ${POLICY_CHECK_NAME} run ${prior.id} (success) on ${pr.head.sha}`; + return `PR #${pr.number}: replayed ${POLICY_CHECK_NAME} run ${prior.id} (success) on ${pr.head.sha}; ${path}`; } async function evaluateOnce({ github, context }) { @@ -285,17 +365,18 @@ async function evaluateOnce({ github, context }) { // Post-merge label/comment edits re-fire this event; a closed PR has nothing to gate. if (pr.state === 'closed') return closedNoop(pr); assertEligible(pr, event.head.sha, event.base.ref); - await assertEvidence(github, repo, pr.number, pr.head.sha, POLICY_CHECKS); + const path = await assertEvidence(github, repo, pr.number, pr.head.sha, POLICY_CHECKS, pr); const { data: current } = await github.rest.pulls.get({ ...repo, pull_number: event.number }); if (current.state === 'closed') return closedNoop(current); assertEligible(current, event.head.sha, event.base.ref); - return `PR #${pr.number}: five existing policy providers succeeded on ${pr.head.sha}`; + return `PR #${pr.number}: five existing policy providers succeeded on ${pr.head.sha}; ${path}`; } if (context.eventName !== 'merge_group' || context.payload.action !== 'checks_requested') { throw new Error('Unsupported policy event'); } const group = context.payload.merge_group; const members = await readQueue(github, repo, group); + const paths = []; for (const entry of members) { const { number, headRefOid: head } = entry.pullRequest; const { data: pr } = await github.rest.pulls.get({ ...repo, pull_number: number }); @@ -307,7 +388,7 @@ async function evaluateOnce({ github, context }) { throw new Error(`#${number}: current PR head is not contained in the tested group`); } await assertReviews(github, repo, number, head); - await assertEvidence(github, repo, number, head, { ...POLICY_CHECKS, ...BUILD_CHECKS }); + paths.push(`#${number} ${await assertEvidence(github, repo, number, head, { ...POLICY_CHECKS, ...BUILD_CHECKS }, pr)}`); } // Re-read both membership and mutable gates after all evidence reads. This // bounds TOCTOU, but GitHub/Hive reconciliation is not an atomic transaction. @@ -324,14 +405,14 @@ async function evaluateOnce({ github, context }) { ...repo, ref: group.head_ref.slice('refs/'.length), }); if (ref.object?.sha !== group.head_sha) throw new Error('Synthetic group ref moved'); - return `Group ${group.head_sha}: validated all ${members.length} member heads`; + return `Group ${group.head_sha}: validated all ${members.length} member heads (${paths.join('; ')})`; } module.exports = { ACTIONS_APP_ID, DCO_APP_ID, POLICY_CHECKS, BUILD_CHECKS, PendingEvidence, membersForGroup, assertEligible, evidenceForHead, closedNoop, evaluate, isTransientAPIError, isCosmeticLabelFlip, replayLastVerdict, BLOCKED_LABEL, - ProviderUnavailable, + ProviderUnavailable, FORWARD_MERGE, PROW, DCO_ENUMERATION_SUMMARY_PREFIX, DCO_ENUMERATION_SUMMARY_FALLBACK, DCO_PROVIDER_UNAVAILABLE_TEXT, DCO_PROVIDER_RUNBOOK, }; diff --git a/.github/scripts/native-queue-policy.test.cjs b/.github/scripts/native-queue-policy.test.cjs index c3d3e50f48..742d90ffa7 100644 --- a/.github/scripts/native-queue-policy.test.cjs +++ b/.github/scripts/native-queue-policy.test.cjs @@ -5,7 +5,7 @@ const { ACTIONS_APP_ID, DCO_APP_ID, POLICY_CHECKS, BUILD_CHECKS, PendingEvidence, membersForGroup, assertEligible, evidenceForHead, closedNoop, evaluate, isTransientAPIError, isCosmeticLabelFlip, replayLastVerdict, - ProviderUnavailable, + ProviderUnavailable, FORWARD_MERGE, PROW, DCO_ENUMERATION_SUMMARY_PREFIX, DCO_ENUMERATION_SUMMARY_FALLBACK, DCO_PROVIDER_UNAVAILABLE_TEXT, @@ -206,6 +206,99 @@ test('UNKNOWN reporting requires trusted exact-head completed DCO and the specif error => !(error instanceof ProviderUnavailable) && error.message === 'DCO: failure'); }); +// #17030: v6-topup.yml's PR whose probot DCO rejects a commit already on v5. +function forwardMergeFixture() { + const f = fixture('pull_request_target'); + Object.assign(f.state.prs[0], { + head: { sha: sha(11), ref: 'sync/v5-to-v6', repo: { full_name: 'acme/widget' } }, + base: { ref: 'v6' }, user: { ...FORWARD_MERGE.author }, + }); + f.context.payload.pull_request = clone(f.state.prs[0]); + f.state.runs.get(sha(11)).find(r => r.name === 'DCO').conclusion = 'action_required'; + // sha(201) is the v5 commit probot rejects; sha(11) is the top-up merge of + // v5 (sha(201)) onto v6 (sha(300)). + f.state.commits = [ + { sha: sha(201), parents: [{ sha: sha(200) }] }, + { sha: sha(11), parents: [{ sha: sha(300) }, { sha: sha(201) }] }, + ]; + f.state.reachable = new Set([`v5...${sha(201)}`, `v6...${sha(300)}`]); + f.state.statuses = [ + { id: 1, context: 'dco', state: 'success', creator: { login: PROW.login, id: PROW.id } }, + ]; + f.github.rest.pulls.listCommits = 'commits'; + f.github.rest.repos.listCommitStatusesForRef = 'statuses'; + f.github.rest.repos.compareCommitsWithBasehead = async ({ basehead }) => { + f.state.seen.push(basehead); + return { data: { status: f.state.reachable.has(basehead) ? 'behind' : 'diverged' } }; + }; + const basePaginate = f.github.paginate; + f.github.paginate = async (method, args) => { + if (method === 'commits') return clone(f.state.commits); + if (method === 'statuses') return clone(f.state.statuses); + return basePaginate(method, args); + }; + return f; +} + +test('v5-reachable sync/v5-to-v6 forward-merge passes on prow dco without probot DCO', async () => { + const f = forwardMergeFixture(); + assert.match(await evaluate(f), + /five existing policy providers succeeded.*DCO path: prow dco for v5-reachable sync\/v5-to-v6 forward-merge/); + assert.deepEqual(f.state.seen, [`v5...${sha(201)}`, `v6...${sha(300)}`, `v5...${sha(201)}`]); +}); + +test('one commit unreachable from v5 keeps the forward-merge on probot DCO', async () => { + const unreachable = forwardMergeFixture(); + unreachable.state.reachable.delete(`v5...${sha(201)}`); + await assert.rejects(evaluate(unreachable), /DCO: action_required.*probot DCO.*not reachable from v5/); + const extra = forwardMergeFixture(); + extra.state.commits.splice(1, 0, { sha: sha(202), parents: [{ sha: sha(201) }] }); + await assert.rejects(evaluate(extra), new RegExp(`DCO: action_required.*${sha(202)} is not reachable from v5`)); + for (const parents of [[{ sha: sha(201) }], [{ sha: sha(301) }, { sha: sha(201) }], [{ sha: sha(300) }, { sha: sha(202) }]]) { + const notMerge = forwardMergeFixture(); + notMerge.state.commits[1].parents = parents; + await assert.rejects(evaluate(notMerge), /DCO: action_required.*is not a merge of v5 into v6/); + } + const truncated = forwardMergeFixture(); + truncated.state.commits = Array.from({ length: 250 }, (_, i) => ({ sha: sha(1000 + i), parents: [] })); + await assert.rejects(evaluate(truncated), /DCO: action_required.*commit list unverifiable/); + // Probot DCO succeeding still admits through the unchanged path. + unreachable.state.runs.get(sha(11)).find(r => r.name === 'DCO').conclusion = 'success'; + assert.match(await evaluate(unreachable), /DCO path: probot DCO \(App 1861\); sync\/v5-to-v6 fallback/); +}); + +test('another head branch, base, fork or author keeps requiring probot DCO', async () => { + for (const change of [ + pr => { pr.head.ref = 'sync/v5-to-v6-extra'; }, + pr => { pr.head.repo.full_name = 'fork/widget'; }, + pr => { pr.user = { login: 'clubanderson', id: 1, type: 'User' }; }, + pr => { pr.user.id = 1; }, + pr => { pr.user.login = 'hivecommons-hive[bot]'; }, + ]) { + const f = forwardMergeFixture(); + change(f.state.prs[0]); + await assert.rejects(evaluate(f), error => error.message === 'DCO: action_required'); + assert.equal(f.state.seen.length, 0); + } + const v5 = forwardMergeFixture(); + v5.state.prs[0].base.ref = 'v5'; + v5.context.payload.pull_request.base.ref = 'v5'; + await assert.rejects(evaluate(v5), error => error.message === 'DCO: action_required'); +}); + +test('forward-merge path fails without a successful prow-created dco status', async () => { + const failed = forwardMergeFixture(); + failed.state.statuses.push({ id: 2, context: 'dco', state: 'failure', creator: { login: PROW.login, id: PROW.id } }); + await assert.rejects(evaluate(failed), /prow dco: failure.*DCO path: prow dco/); + // Any workflow token can post a `dco` status; it never stands in for prow. + const forged = forwardMergeFixture(); + forged.state.statuses = [{ id: 3, context: 'dco', state: 'success', creator: { login: 'github-actions[bot]', id: 41898282 } }]; + await assert.rejects(evaluate(forged), error => error instanceof PendingEvidence && /Missing prow dco/.test(error.message)); + const pending = forwardMergeFixture(); + pending.state.statuses[0].state = 'pending'; + await assert.rejects(evaluate(pending), error => error instanceof PendingEvidence); +}); + test('draft, closed, held and moved-head/base PRs cannot pass', () => { for (const change of [ { draft: true }, { state: 'closed' }, { head: { sha: sha(99) } }, { base: { ref: 'v6' } }, diff --git a/src/docs/native-merge-queue.md b/src/docs/native-merge-queue.md index be526e74c3..11f1a0bdd8 100644 --- a/src/docs/native-merge-queue.md +++ b/src/docs/native-merge-queue.md @@ -246,6 +246,18 @@ metadata, not a fabricated last-member PR event. this bridge does not turn its underlying implementation into a strict content validator. Dependabot runs that same trusted PR-target verifier rather than skipping it; skipped policy evidence is never exempted by actor. +- One narrow exception replaces probot `DCO` (#17030): a PR whose head + branch is exactly `sync/v5-to-v6` in this repository, whose base is `v6`, + and which was opened by `github-actions[bot]` (the `v6-topup.yml` + identity). Every PR commit except the head must be reachable from `v5` + (compare API `v5...` is `behind`/`identical`), the head must be the + top-up's two-parent merge of `v5` history onto `v6` history, and the list + must stay under the REST 250-commit cap. Those commits already passed v5's + DCO gate and probot cannot be repaired PR-side, so the latest prow `dco` + commit status created by `kubestellar-prow[bot]` must be `success` instead; + a `dco` status from any other creator is ignored. Any unmet condition falls + back to requiring probot `DCO`. The check output names the DCO path taken + and, on fallback, why. - Draft/held PRs, changes requested, dismissed approvals and approvals on an old head fail closed. A `pull_request_target` run on an already closed or merged PR (re-fired by a post-merge label or comment edit) passes as a @@ -390,7 +402,8 @@ handles rejected/broken heads; there is no second fixer or merge engine. history, admission reports **DCO provider unavailable / verdict UNKNOWN** and remains blocked. Follow the [provider diagnosis and recovery runbook](operator-reference/dco-provider-unavailable.md); a provider enumeration failure does not request a PR source change or permit - substitution of the lowercase prow `dco` status. + substitution of the lowercase prow `dco` status outside the narrow + `sync/v5-to-v6` forward-merge path above. - Inspect the PR's exact-head checks and the **group SHA** checks separately. A green member head does not establish green integration evidence. `native-queue-policy` logs the failing provider, provenance, membership, diff --git a/src/docs/operator-reference/dco-provider-unavailable.md b/src/docs/operator-reference/dco-provider-unavailable.md index 7c4d51e086..008b69d89b 100644 --- a/src/docs/operator-reference/dco-provider-unavailable.md +++ b/src/docs/operator-reference/dco-provider-unavailable.md @@ -101,3 +101,7 @@ Preserve the true merge ancestry of #16378. Splitting/rebasing the forward merge, adding empty commits, accepting the lowercase prow `dco` status, or weakening protection does not repair this provider failure. Until authoritative current-head DCO success exists, the correct admission outcome remains blocked. +The only exception is the narrow `sync/v5-to-v6` forward-merge path in +[native-merge-queue.md](../native-merge-queue.md#required-checks-and-provider-boundaries) +(#17030), where every carried commit is already on `v5`; any other PR, or a +top-up carrying a commit not reachable from `v5`, still needs App-1861 DCO.