From 9cbfbf3c910bb151296b7e369f515d27fdd52715 Mon Sep 17 00:00:00 2001 From: James Dumay Date: Wed, 25 Nov 2026 12:01:21 +1100 Subject: [PATCH] Restore automatic inference qualification for matching PRs --- .agents/skills/manage-ci/SKILL.md | 12 ++-- .../fixtures/inference-skipped-plan.json | 11 +++ .github/scripts/inference-schedule.test.cjs | 27 ++++++- .github/scripts/pr-checks.cjs | 3 + .github/scripts/pr-checks.test.cjs | 71 ++++++++++++++++--- .github/scripts/pr-inference-checks.cjs | 28 ++++++++ .github/workflows/inference.yml | 20 ++---- ci/README.md | 19 +++-- 8 files changed, 151 insertions(+), 40 deletions(-) create mode 100644 .github/scripts/fixtures/inference-skipped-plan.json create mode 100644 .github/scripts/pr-inference-checks.cjs diff --git a/.agents/skills/manage-ci/SKILL.md b/.agents/skills/manage-ci/SKILL.md index 160b12b7..2c581296 100644 --- a/.agents/skills/manage-ci/SKILL.md +++ b/.agents/skills/manage-ci/SKILL.md @@ -12,7 +12,10 @@ contract; no downstream product's workflow topology applies here. aggregate on the repository's selected Ubuntu runner. Protected-main code reads workflow/check/status results without executing candidate code or using lab credentials. Failures/cancellations fail it; pending or missing applicable work - stays pending; success/neutral/intentional skips pass. Producer starts and + stays pending; success/neutral/intentional skips pass except required inference + qualification, whose plan, summary and complete protected PR roster must + succeed in the latest run, using each job's latest execution (partial reruns + may inherit successful jobs). Producer starts and completions re-evaluate reruns; latest exact-head results govern. Add new PR producer workflows to its event list. Activate the one-check branch rule only after the controller reaches main and its real aggregate is verified; preserve @@ -38,10 +41,9 @@ contract; no downstream product's workflow topology applies here. and failed pushes cannot hide untested inputs. If previous coverage cannot be verified, require both device smokes and Graph Contracts. The protected inference workflow uses its separate qualification paths in its native - trigger for the seven Spark configurations. PR qualification is manual: the - jobs run only when the PR carries the `qualify` label, while the workflow - still triggers on path matches so an intentionally skipped run satisfies - the `PR checks` aggregate; nightly and releases stay automatic. Main pushes + trigger for the seven Spark configurations. Matching PRs automatically run + qualification on each head without a label. Skipped admission or matrix jobs + cannot satisfy qualification or `PR checks`; nightly and releases stay automatic. Main pushes do not start the Spark ladder. `PR checks` reads protected trigger paths to determine which runs it expects. Hosted offline automation gates Quality canary and package jobs; Quality canary gates package diff --git a/.github/scripts/fixtures/inference-skipped-plan.json b/.github/scripts/fixtures/inference-skipped-plan.json new file mode 100644 index 00000000..79aa379b --- /dev/null +++ b/.github/scripts/fixtures/inference-skipped-plan.json @@ -0,0 +1,11 @@ +{ + "url": "https://github.com/Mesh-LLM/skippy/actions/runs/45489845896", + "run": {"id": 45489845896, "run_attempt": 1, "conclusion": "success"}, + "jobs": [ + {"id": 138784923060, "name": "summary", "run_attempt": 1, "status": "completed", "conclusion": "success"}, + {"id": 138784924701, "name": "plan", "run_attempt": 1, "status": "completed", "conclusion": "skipped"}, + {"id": 138784925358, "name": "Publish nightly qualification", "run_attempt": 1, "status": "completed", "conclusion": "skipped"}, + {"id": 138785012334, "name": "qualification (${{ matrix.id }})", "run_attempt": 1, "status": "completed", "conclusion": "skipped"}, + {"id": 138785264336, "name": "report", "run_attempt": 1, "status": "completed", "conclusion": "skipped"} + ] +} diff --git a/.github/scripts/inference-schedule.test.cjs b/.github/scripts/inference-schedule.test.cjs index 38b5db6e..a09eb756 100644 --- a/.github/scripts/inference-schedule.test.cjs +++ b/.github/scripts/inference-schedule.test.cjs @@ -36,12 +36,12 @@ const script = summary.split(' script: |\n')[1].replace(/^ {12}/gm, '') const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; const evaluate = new AsyncFunction('process', 'context', 'github', 'core', script); -async function status(profile, publication, result = 'success') { +async function status(profile, publication, result = 'success', plan = 'success', eventName = 'schedule') { const statuses = [], failures = []; await evaluate({ env: { - SOURCE_SHA: 'a'.repeat(40), PROFILE: profile, PLAN: 'success', RESULT: result, + SOURCE_SHA: 'a'.repeat(40), PROFILE: profile, PLAN: plan, RESULT: result, PUBLICATION: publication, RUN_URL: 'https://example.invalid/run', - } }, { eventName: 'schedule', repo: { owner: 'Mesh-LLM', repo: 'skippy' } }, { + } }, { eventName, repo: { owner: 'Mesh-LLM', repo: 'skippy' } }, { rest: { repos: { createCommitStatus: async value => statuses.push(value) } }, }, { setFailed: message => failures.push(message) }); return { state: statuses[0].state, failures }; @@ -54,3 +54,24 @@ test('scheduled release success does not require nightly publication, while nigh assert.equal((await status('nightly', 'skipped')).state, 'failure'); assert.equal((await status('release', 'skipped', 'failure')).state, 'failure'); }); + +test('matching PRs always plan qualification without a label or label-change event', () => { + const trigger = workflow.split('\n schedule:\n')[0]; + assert.match(trigger, /types: \[opened, synchronize, reopened, ready_for_review\]/); + const plan = workflow.split('\n plan:\n')[1].split('\n qualification:\n')[0]; + assert.doesNotMatch(plan, /^ if:/m); + assert.doesNotMatch(plan, /qualify|labels/); + assert.match(plan, /run: just inference-admit/); + assert.match(plan, /just inference-matrix/); +}); + +test('PR summary requires successful admission and matrix; skipped plans cannot report qualification', async () => { + assert.equal((await status('pr', 'skipped', 'success', 'success', 'pull_request_target')).state, 'success'); + for (const result of ['skipped', 'failure', 'cancelled', '']) { + for (const [plan, matrix] of [[result, 'success'], ['success', result]]) { + const outcome = await status('pr', 'skipped', matrix, plan, 'pull_request_target'); + assert.equal(outcome.state, 'failure', `${plan}/${matrix}`); + assert.equal(outcome.failures.length, 1); + } + } +}); diff --git a/.github/scripts/pr-checks.cjs b/.github/scripts/pr-checks.cjs index d167b678..e524d6a7 100644 --- a/.github/scripts/pr-checks.cjs +++ b/.github/scripts/pr-checks.cjs @@ -1,6 +1,7 @@ // Protected-main controller. It reads candidate metadata but never executes it. const expectedWorkflows = require('./pr-trigger-paths.cjs'); const validateAcceptance = require('./pr-acceptance.cjs'); +const requireInferenceJobs = require('./pr-inference-checks.cjs'); const workflowPath = run => run.path?.split('@')[0]; const automaticPR = run => ['pull_request', 'pull_request_target'].includes(run.event); const accepted = new Set(['success', 'skipped', 'neutral']); @@ -52,9 +53,11 @@ module.exports = async function aggregate({ github, context, core, depot = false let pending = false; for (const run of latest.values()) { const path = workflowPath(run); + const requiredInference = path === '.github/workflows/inference.yml' && expected.get(path) === run.event; if (expected.get(path) === run.event) expected.delete(path); if (run.status !== 'completed') pending = true; else if (!accepted.has(run.conclusion)) throw new Error(`${run.name}: ${run.conclusion || 'incomplete'}`); + else if (requiredInference) await requireInferenceJobs(github, repo, run); } // Include checks from other providers, and independent commit statuses. const checks = await github.paginate(github.rest.checks.listForRef, diff --git a/.github/scripts/pr-checks.test.cjs b/.github/scripts/pr-checks.test.cjs index 1b6b2342..191c4331 100644 --- a/.github/scripts/pr-checks.test.cjs +++ b/.github/scripts/pr-checks.test.cjs @@ -7,45 +7,95 @@ const expectedWorkflows = require('./pr-trigger-paths.cjs'); const sha = '1'.repeat(40); const body = readFileSync(join(__dirname, '../PULL_REQUEST_TEMPLATE.md'), 'utf8').replaceAll('- [ ]', '- [x]'); const inferenceChange = { filename: 'crates/skippy-cli/src/main.rs' }; +const inferenceJobs = () => ['plan', 'summary', ...JSON.parse(readFileSync( + join(__dirname, '../../ci/inference-ladder.json'), 'utf8')).models.filter(model => model.pr).flatMap(model => + [`qualification (${model.id}-standalone)`, ...(model.split ? [`qualification (${model.id}-split)`] : [])])] + .map((name, index) => ({ id: index + 1, name, run_attempt: 1, status: 'completed', conclusion: 'success' })); const run = (path, id = 1, extra = {}) => ({ id, workflow_id: path, path: `.github/workflows/${path}`, name: path, event: path === 'inference.yml' ? 'pull_request_target' : 'pull_request', head_sha: sha, pull_requests: [{ number: 52 }], - status: 'completed', conclusion: 'success', ...extra + status: 'completed', conclusion: 'success', run_attempt: 1, ...extra }); async function evaluate(options = {}) { - const calls = [], failures = []; + const calls = [], failures = [], jobRequests = []; const pr = { number: 52, state: 'open', head: { sha }, body }; let reads = 0; const rest = { pulls: { get: async () => ({ data: ++reads > 1 && options.current ? options.current : { ...pr, ...options.pr } }), listFiles: 'files' }, - actions: { listWorkflowRunsForRepo: 'runs' }, + actions: { listWorkflowRunsForRepo: 'runs', listJobsForWorkflowRun: 'jobs' }, checks: { listForRef: 'checks' }, repos: { listPullRequestsAssociatedWithCommit: 'prs', listCommitStatusesForRef: 'statuses', createCommitStatus: async value => calls.push(value) } }; const data = { files: options.files || [inferenceChange], runs: options.runs || [run('ci.yml'), run('inference.yml')], - checks: options.checks || [], statuses: options.statuses || [], prs: [pr] }; - const github = { rest, paginate: async method => { + checks: options.checks || [], statuses: options.statuses || [], prs: [pr], jobs: options.jobs || inferenceJobs() }; + const github = { rest, paginate: async (method, parameters) => { if (options.apiError === method) throw new Error('GitHub API unavailable'); + if (method === 'jobs') jobRequests.push(parameters); return structuredClone(data[method]); } }; const context = { repo: { owner: 'Mesh-LLM', repo: 'skippy' }, runId: 42, payload: options.payload || { pull_request: pr } }; await aggregate({ github, context, depot: options.depot, core: { info() {}, setFailed: message => failures.push(message) } }); assert.ok(calls.every(c => c.sha === sha && c.context === 'PR checks')); - return { state: calls.at(-1)?.state, calls, failures }; + return { state: calls.at(-1)?.state, calls, failures, jobRequests }; } -test('success for all completed work and explicit skips; no model claim', async () => { +test('unlabeled inference PRs require qualification; unrelated jobs may intentionally skip', async () => { for (const conclusion of ['success', 'skipped', 'neutral']) { - const result = await evaluate({ runs: [run('ci.yml'), run('inference.yml', 2, { conclusion })] }); + const result = await evaluate({ pr: { labels: [] }, runs: [run('ci.yml', 1, { conclusion }), run('inference.yml', 2)] }); assert.equal(result.state, 'success'); assert.deepEqual(result.failures, []); } }); +test('green skipped plans, skipped matrix rows and incomplete inference cannot satisfy the gate', async () => { + for (const name of inferenceJobs().map(job => job.name)) { + for (const conclusion of ['skipped', 'neutral', 'failure', 'cancelled', null]) { + const jobs = inferenceJobs().map(job => job.name === name ? { ...job, conclusion } : job); + assert.equal((await evaluate({ jobs })).state, 'failure', `${name}: ${conclusion}`); + } + assert.equal((await evaluate({ jobs: inferenceJobs().filter(job => job.name !== name) })).state, 'failure', name); + } + for (const conclusion of ['skipped', 'neutral']) { + assert.equal((await evaluate({ runs: [run('ci.yml'), run('inference.yml', 2, { conclusion })] })).state, 'failure'); + } +}); + +test('the real green skipped qualification run from recovery PR 201 is rejected', async () => { + const fixture = require('./fixtures/inference-skipped-plan.json'); + const result = await evaluate({ runs: [run('ci.yml'), run('inference.yml', fixture.run.id, fixture.run)], jobs: fixture.jobs }); + assert.equal(result.state, 'failure'); + assert.match(result.failures[0], /Inference qualification: plan: skipped/); +}); + +test('only the latest exact-head inference run supplies job evidence', async () => { + const result = await evaluate({ runs: [run('ci.yml'), run('inference.yml', 2), + run('inference.yml', 3, { run_attempt: 2 }), run('inference.yml', 4, { head_sha: '2'.repeat(40) })] }); + assert.equal(result.state, 'success'); + assert.deepEqual(result.jobRequests, [{ owner: 'Mesh-LLM', repo: 'skippy', run_id: 3, filter: 'all', per_page: 100 }]); + assert.equal((await evaluate({ runs: [run('ci.yml'), run('inference.yml', 2, { head_sha: '2'.repeat(40) })] })).state, 'pending'); +}); + +test('partial reruns inherit successful jobs but newer skips or failures override older success', async () => { + const runs = [run('ci.yml'), run('inference.yml', 2, { run_attempt: 2 })]; + const original = inferenceJobs(); + const failedRow = original.find(job => job.name.startsWith('qualification (')); + const summary = original.find(job => job.name === 'summary'); + const firstAttempt = original.map(job => [failedRow.name, summary.name].includes(job.name) + ? { ...job, conclusion: 'failure' } : job); + const rerun = [failedRow, summary].map(job => ({ ...job, id: job.id + 100, run_attempt: 2 })); + assert.equal((await evaluate({ runs, jobs: [...rerun, ...firstAttempt] })).state, 'success'); + for (const conclusion of ['skipped', 'failure', 'cancelled']) { + assert.equal((await evaluate({ runs, jobs: [...original, + { ...failedRow, id: 100, run_attempt: 2, conclusion }] })).state, 'failure'); + } + assert.equal((await evaluate({ runs, jobs: [...original, + { ...failedRow, id: 100, run_attempt: 3 }] })).state, 'failure'); +}); + test('missing, queued, running and waiting workflows remain pending', async () => { assert.equal((await evaluate({ runs: [] })).state, 'pending'); for (const status of ['queued', 'in_progress', 'waiting', 'pending']) { @@ -105,6 +155,9 @@ test('native trigger patterns distinguish metadata, code-only, inference and mix ['crates/skippy-cli/tests/smoke.rs', ['ci.yml']], ['crates/skippy-cli/src/helper_tests.rs', ['ci.yml']], ['crates/skippy-cli/src/main.rs', ['ci.yml', 'inference.yml']], + ['crates/skippy-runtime/src/session.rs', ['ci.yml', 'inference.yml']], + ['llama_cpp/upstream.txt', ['ci.yml', 'inference.yml']], + ['llama_cpp/patches/model_support/0024-layout.patch', ['ci.yml', 'inference.yml']], ['ci/inference-ladder.json', ['ci.yml', 'inference.yml']], ['scripts/inference-execute.py', ['ci.yml', 'inference.yml']], ['scripts/lib/inference_inputs.py', ['ci.yml', 'inference.yml']], @@ -218,7 +271,7 @@ test('independent check runs and latest commit statuses also block or wait', asy }); test('API failures cannot become successful aggregate results', async () => { - for (const apiError of ['files', 'runs', 'checks', 'statuses']) { + for (const apiError of ['files', 'runs', 'jobs', 'checks', 'statuses']) { const result = await evaluate({ apiError }); assert.equal(result.state, 'failure'); assert.equal(result.failures.length, 1); diff --git a/.github/scripts/pr-inference-checks.cjs b/.github/scripts/pr-inference-checks.cjs new file mode 100644 index 00000000..92b6b5b8 --- /dev/null +++ b/.github/scripts/pr-inference-checks.cjs @@ -0,0 +1,28 @@ +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Read only the protected roster used by the inference controller. A green +// workflow with a skipped plan (the former label policy) is not qualification. +module.exports = async function requireInferenceJobs(github, repo, run) { + if (run.conclusion !== 'success') throw new Error(`Inference qualification: ${run.conclusion}`); + const { models } = JSON.parse(readFileSync(join(__dirname, '../../ci/inference-ladder.json'), 'utf8')); + const configurations = models.filter(model => model.pr).flatMap(model => + [model.id + '-standalone', ...(model.split ? [model.id + '-split'] : [])]); + if (!configurations.length) throw new Error('Inference qualification: empty PR roster'); + const required = ['plan', 'summary', ...configurations.map(id => `qualification (${id})`)]; + // Partial reruns inherit successful jobs. Read this run's history and use + // each job's latest execution, so an older success cannot mask a new skip. + const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRun, + { ...repo, run_id: run.id, filter: 'all', per_page: 100 }); + const latest = new Map(); + for (const job of jobs) { + if (job.run_attempt > run.run_attempt) throw new Error('Inference qualification: run attempt changed'); + if (!latest.has(job.name) || latest.get(job.name).id < job.id) latest.set(job.name, job); + } + for (const name of required) { + const job = latest.get(name); + if (job?.status !== 'completed' || job.conclusion !== 'success') { + throw new Error(`Inference qualification: ${name}: ${job?.conclusion || 'missing or incomplete'}`); + } + } +}; diff --git a/.github/workflows/inference.yml b/.github/workflows/inference.yml index 94a2a4ec..b9df9172 100644 --- a/.github/workflows/inference.yml +++ b/.github/workflows/inference.yml @@ -1,7 +1,7 @@ name: Inference qualification on: pull_request_target: - types: [opened, synchronize, reopened, ready_for_review, labeled] + types: [opened, synchronize, reopened, ready_for_review] paths: - 'crates/**' - 'skippy_api/src/**' @@ -86,13 +86,7 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request_target' }} jobs: plan: - # PR qualification is manual: it runs only when the `qualify` label is - # present, so atomic Spark pairs are reserved on request rather than by - # every inference-path push. The workflow still triggers on path matches - # so an intentionally skipped run satisfies the PR checks aggregate. - if: >- - github.event_name != 'pull_request_target' || - contains(github.event.pull_request.labels.*.name, 'qualify') + # Matching PR paths always require admission and native qualification. runs-on: ${{ vars.SKIPPY_DEPOT_RUNNERS_ENABLED == 'true' && 'depot-ubuntu-24.04-4' || 'ubuntu-24.04' }} timeout-minutes: 20 outputs: @@ -229,26 +223,20 @@ jobs: script: | const { SOURCE_SHA: sha, PROFILE: profile, PLAN: plan, RESULT: result, PUBLICATION: publication, RUN_URL: url } = process.env; if (!/^[a-f0-9]{40}$/i.test(sha)) throw new Error('Invalid qualification source SHA'); - // A skipped plan is an intentional opt-out: the PR carries no - // qualify label, so no Spark pair was reserved. Report it green - // instead of failing unlabeled PRs. - const skipped = plan === 'skipped'; // A reusable call from a scheduled Release also inherits schedule. const nightly = context.eventName === 'schedule' && profile === 'nightly'; const passed = plan === 'success' && result === 'success' && (!nightly || publication === 'success'); const description = passed ? 'Native Spark lab qualification' - : skipped - ? 'Intentionally skipped (no qualify label)' : nightly ? 'Nightly qualification or publication incomplete or failed' : 'Inference admission or qualification incomplete or failed'; await github.rest.repos.createCommitStatus({ ...context.repo, sha, context: 'Inference qualification', - state: passed || skipped ? 'success' : 'failure', description, target_url: url + state: passed ? 'success' : 'failure', description, target_url: url }); - if (!passed && !skipped) core.setFailed(description); + if (!passed) core.setFailed(description); report: needs: [plan, qualification, summary] diff --git a/ci/README.md b/ci/README.md index a2c889a4..5c862ea1 100644 --- a/ci/README.md +++ b/ci/README.md @@ -12,7 +12,11 @@ execution, model inputs or lab credentials. It re-evaluates on PR events and producer workflow starts/completions, including reruns. Failed, cancelled, timed-out and startup-failed runs fail the gate; queued/running or missing applicable workflows leave it pending. Successful, neutral and intentionally -skipped results are accepted. Results bind to the current PR head; older runs +skipped results are accepted except for required inference qualification. Its +latest run must contain successful plan, summary and every PR matrix job selected +by the protected inference ladder. Each job's latest execution governs, including +successful jobs inherited by partial reruns; a green workflow with skipped jobs +does not count. Results bind to the current PR head; older runs and attempts cannot override newer results. It includes additional automatic PR workflows and independent checks/statuses, rather than requiring their names in branch protection. The aggregate reads the native PR trigger paths for CI, @@ -51,7 +55,7 @@ and no exclusion. The routes are independent; mixed PRs run all applicable work. | `automation` | Hosted offline Python, Node and shell contracts, including report/publication tests. No Rust setup, native source, compiler image or model inputs. | | `code` | Quality canary: formatting, Clippy, FFI, Rust and C++ tests, after automation passes. | | `packages` | Linux ARM64 CUDA 13 and macOS ARM64 Metal builds and packaged inference on real devices, after automation and any applicable source checks pass. | -| `inference` | The separate qualification workflow, using its native trigger list and the existing manual PR policy. | +| `inference` | Automatic qualification on each matching PR head, using the separate workflow's native trigger list. | On PRs, runtime source and package/build/smoke inputs select device package smoke. Qualification planning, dispatch, scoring, baselines and publication select @@ -88,10 +92,11 @@ require all thirteen packages and Graph Contracts. Main merges do not start the separate Spark qualification ladder. The protected inference workflow has its own qualification paths, separate from -package smoke. PR qualification is manual: it runs only when the PR carries the -`qualify` label. The workflow still triggers on matching paths so its intentional -skip satisfies the `PR checks` aggregate. The label does not control package smoke. -Manual qualification may queue behind another PR's atomic Spark pair; the PR +package smoke. Matching PRs automatically run qualification on opening, +synchronization, reopening and readiness for review; no `qualify` label is needed. +Label changes do not restart or cancel qualification. Skipped admission or matrix +jobs fail qualification and cannot satisfy `PR checks`. +Qualification may queue behind another PR's atomic Spark pair; the PR budget waits for placement instead of failing fast. Relevant PRs retain same-repository/collaborator admission, a fresh-head check and all seven GPU smoke configurations. The credentialed controller runs only protected source. @@ -126,7 +131,7 @@ just inference-render-report summary "$examples/examples.json" --run pr-pass The scheduled inference workflow runs the twelve nightly AgentX configurations and the seven PR-profile smoke configurations. The smoke runs use the same -harness as labeled PRs. PR smoke, nightly, and release qualification allow +harness as automatically qualified PRs. PR smoke, nightly, and release qualification allow experimental split admission, retain the actual admission status, and require the full checks for their profile.