diff --git a/README.md b/README.md index 6039d51..0751c65 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,11 @@ A clean review can retain settled `disputed` findings in its ledger so later rounds remember the rebuttals. Profile receipt validation rejects open findings; retained settled findings do not block proof or authorize unresolved GitHub threads. +The final CI race check blocks matching active reviews and reviews completing at +or after proof starts. Older completed branch-workflow audits do not invalidate +a newer trusted-main proof; the review used for authorization must still pass +all current caller, pin, receipt, and proof checks. + ### Baseline panels | Profile | Standard (auto) | Deep (maintainer dispatch) | diff --git a/scripts/profile_consumer.mjs b/scripts/profile_consumer.mjs index 0d286c4..b999ea6 100644 --- a/scripts/profile_consumer.mjs +++ b/scripts/profile_consumer.mjs @@ -569,7 +569,7 @@ async function reviewRaceBlocksAuthorization( context, { pullNumber, headSha, createdAt, proofStartedAt, currentReviewRun }, ) { - const { owner, repo, repository, defaultBranch, reviewPin, trustedCallerSha } = context; + const { owner, repo } = context; if (currentReviewRun.status !== 'completed') { throw new Error('current review run is not completed'); } @@ -594,11 +594,12 @@ async function reviewRaceBlocksAuthorization( if (!runMatchesPull(run, pullNumber, headSha)) { continue; } - try { - await verifyReviewRunProvenance(github, context, run); - } catch { - throw new Error('matching review run has untrusted provenance'); - } + // This scan only invalidates proof; it never authorizes a review. The + // authoritative review and completed proof have already passed provenance. + // Older branch-caller audits are expected during a workflow-pin migration; + // they are not races once they finish before that trusted proof starts. + // Any matching active or later-completing run still blocks authorization, + // including runs that would fail provenance themselves. if (run.status !== 'completed') { throw new Error('a newer matching review run is still active'); } diff --git a/tests/profile-consumer.test.mjs b/tests/profile-consumer.test.mjs index 9edd8a4..0576445 100644 --- a/tests/profile-consumer.test.mjs +++ b/tests/profile-consumer.test.mjs @@ -521,6 +521,43 @@ describe('authorizeProfileReceipt', () => { assert.equal(result.authorized, true); }); + it('allows an older branch-caller audit before a newer trusted profile proof', async () => { + const { github, store } = buildStore({ + reviewRuns: [ + reviewRun(), + reviewRun({ id: 101, referenced_workflows: [], updated_at: '2024-01-02T09:55:00Z' }), + ], + }); + const result = await authorizeProfileReceipt(github, authorizeContext(store)); + assert.equal(result.authorized, true); + }); + + for (const status of ['queued', 'in_progress', 'waiting', 'pending', 'requested']) { + it(`blocks a matching untrusted ${status} run even when it predates the proof`, async () => { + const { github, store } = buildStore({ + reviewRuns: [reviewRun(), reviewRun({ + id: 101, status, conclusion: null, referenced_workflows: [], + updated_at: '2024-01-02T09:55:00Z', + })], + }); + const result = await authorizeProfileReceipt(github, authorizeContext(store)); + assert.equal(result.authorized, false); + assert.match(result.reason, /still active/i); + }); + } + + for (const updatedAt of [PROOF_STARTED, '2024-01-02T10:01:00Z', 'invalid']) { + it(`blocks a matching untrusted completion at ${updatedAt}`, async () => { + const { github, store } = buildStore({ + reviewRuns: [reviewRun(), reviewRun({ + id: 101, referenced_workflows: [], updated_at: updatedAt, + })], + }); + const result = await authorizeProfileReceipt(github, authorizeContext(store)); + assert.equal(result.authorized, false); + }); + } + it('does not attribute a workflow_dispatch on main via empty pull_requests', async () => { const { github, store } = buildStore({ reviewRuns: [