Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .agents/skills/manage-ci/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions .github/scripts/fixtures/inference-skipped-plan.json
Original file line number Diff line number Diff line change
@@ -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"}
]
}
27 changes: 24 additions & 3 deletions .github/scripts/inference-schedule.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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);
}
}
});
3 changes: 3 additions & 0 deletions .github/scripts/pr-checks.cjs
Original file line number Diff line number Diff line change
@@ -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']);
Expand Down Expand Up @@ -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,
Expand Down
71 changes: 62 additions & 9 deletions .github/scripts/pr-checks.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down Expand Up @@ -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']],
Expand Down Expand Up @@ -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);
Expand Down
28 changes: 28 additions & 0 deletions .github/scripts/pr-inference-checks.cjs
Original file line number Diff line number Diff line change
@@ -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'}`);
}
}
};
20 changes: 4 additions & 16 deletions .github/workflows/inference.yml
Original file line number Diff line number Diff line change
@@ -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/**'
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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]
Expand Down
Loading
Loading