From c71719f4c7cbaf7f1f9eeb64846e6e1cc88905a9 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 14:40:52 +0000 Subject: [PATCH 1/3] feat(qa): skill-evals --case runs the named cases alone; any-of prose in the cli header and README Claude-Session: https://claude.ai/code/session_016WV4cxBECSPtHxQMZDHSie Co-authored-by: Claude --- packages/qa/scenarios/README.md | 14 +++- .../qa/scenarios/src/skill-evals/cases.ts | 32 +++++++ packages/qa/scenarios/src/skill-evals/cli.ts | 75 +++++++++++++---- .../qa/scenarios/src/skill-evals/self-test.ts | 83 ++++++++++++++++++- .../qa/scenarios/src/skill-evals/summary.ts | 2 +- 5 files changed, 187 insertions(+), 19 deletions(-) diff --git a/packages/qa/scenarios/README.md b/packages/qa/scenarios/README.md index 838f716cdc8..da9a633746b 100644 --- a/packages/qa/scenarios/README.md +++ b/packages/qa/scenarios/README.md @@ -1010,6 +1010,7 @@ pnpm --filter @objectstack/scenarios skill-evals --skills objectstack-query --re pnpm --filter @objectstack/scenarios skill-evals --skills-from 18.5.0 # a published @objectstack/skills version's bundles and cases pnpm --filter @objectstack/scenarios skill-evals --skills objectstack-query --triggers-only # its trigger cases alone pnpm --filter @objectstack/scenarios skill-evals --skills objectstack-query,objectstack-ask --triggers-only # both installed in every trigger turn +pnpm --filter @objectstack/scenarios skill-evals --case objectstack-ai/skills-tools-knowledge#6 --repeats 10 # one case, both arms pnpm --filter @objectstack/scenarios skill-evals --regrade DIR # re-draw a recorded round's verdicts from its records; no model call pnpm --filter @objectstack/scenarios skill-evals --self-test # the runner's own fixtures; no model call ``` @@ -1031,7 +1032,8 @@ pnpm --filter @objectstack/scenarios skill-evals --self-test # the runner's o share one literal: `[["ai:approve", "signed-in session"], ["refused", "403"]]` reads "(the first or the second) and (the third or the fourth)". The reader refuses a group that is empty or holds an empty token, and a case with no token in any of the three forms. A failing record names each unmet group whole in `unmetAny` (the key is absent when - every group is met), and the summary's missed column prints it as `(none of: a / b)`. A turn whose init line shows the wrong arm is `invalid`: the with-skill arm does not list the bundle, or + every group is met), and the summary's missed column prints it as ``(none of: `a` / `b`)``, each token in its own + code span like the all-of tokens beside it (`summary.github.md` spells angle brackets in them out as `(lt)` / `(gt)`). A turn whose init line shows the wrong arm is `invalid`: the with-skill arm does not list the bundle, or the no-skill arm lists one or launches one. A bundle whose `SKILL.md` sets `user-invocable: false` (`objectui`) is never in the init line's `skills` list, though the model can launch it. Its with-skill turns are graded, and each record's `armEvidence` says whether the turn launched the bundle (`launched`) or nothing in the stream shows it @@ -1060,6 +1062,16 @@ pnpm --filter @objectstack/scenarios skill-evals --self-test # the runner's o installed as a competitor while another named bundle has one; alone, or under `--trigger-field own`, it is refused (a published version before trigger cases has none). The flag is refused beside `--regrade` or `--self-test`. `--dry-run` prints the reduced plan, and `--skills-from VERSION` runs it on the published bundles. +- **`--case KEY[,KEY]`**: the named cases alone, for an acceptance round on one or two cases. A key is the case's key + as the summary and each record print it, `BUNDLE/FILE_STEM#ID` (`objectstack-query/filters-pagination-search#3`): + ids repeat across a bundle's eval files, so a bundle and an id alone would not name one case. The flag repeats, and + the plan keeps catalog order. A behaviour case runs on both arms and a trigger case on the with-skill arm, as in a + whole round. A key that names no case is refused with where it stopped matching: the bundle, the eval file, or the + id, with the ones that exist. Beside `--skills`, every named case must be of a `--skills` bundle, and `--skills` + still sets what a trigger turn installs beside its bundle; without it, a trigger turn installs every bundle, as in + a whole round. It is refused beside `--triggers-only` (the keys already say which cases run), `--regrade` and + `--self-test`. `round.json` records the keys as `scope.selectedCases`, the summary header lists them, and + `--regrade DIR` keeps that scope. `--dry-run` prints the plan with only those cases. - **Case files**: a case's `files` entries are paths under the bundle's `evals/files/` (anything else is refused, and so is a path the bundle lacks or one with a `.claude` segment, since `.claude/` is where the runner places the skill). Each is copied, a directory whole, into both arms' directories at its path below `evals/files/`, so the arms still differ only in the bundle. A case whose prompt states its context needs none. diff --git a/packages/qa/scenarios/src/skill-evals/cases.ts b/packages/qa/scenarios/src/skill-evals/cases.ts index 50222878274..1551cfbb573 100644 --- a/packages/qa/scenarios/src/skill-evals/cases.ts +++ b/packages/qa/scenarios/src/skill-evals/cases.ts @@ -321,3 +321,35 @@ export function selectBundles(catalog: SkillEvalCatalog, names: readonly string[ if (noCases.length && !(competing && picked.some((c) => c.shouldTrigger !== undefined))) throw new Error(`--skills names ${noCases.map((n) => `\`${n}\``).join(', ')}, a bundle with no ${kind} under ${catalog.root}`); return picked; } + +/** A `--case` key's shape: `BUNDLE/FILE_STEM#ID`, the key the summary and every record print. */ +export const CASE_KEY_SHAPE = /^[^/#\s]+\/[^\s]+#[^\s]+$/; + +/** + * Narrow a selection (`selectBundles`' answer) to the cases `--case` names by + * key, kept in catalog order. A key that names no case of the selection is + * refused, never dropped, and the refusal says where it stopped matching: a + * bundle the catalog lacks, a bundle `--skills` leaves out, an eval file the + * bundle lacks, or an id that file does not hold. A misspelt case would + * otherwise plan nothing for it and read as a clean round. Pure. + */ +export function selectCases(catalog: SkillEvalCatalog, selection: readonly SkillEvalCase[], keys: readonly string[], skills?: readonly string[]): SkillEvalCase[] { + const list = (xs: readonly string[]) => xs.map((x) => `\`${x}\``).join(', ') || 'none'; + for (const key of keys) { + if (selection.some((c) => c.key === key)) continue; + const slash = key.indexOf('/'); + const hash = key.lastIndexOf('#'); + const bundle = key.slice(0, slash); + const stem = key.slice(slash + 1, hash); + const id = key.slice(hash + 1); + if (!catalog.bundles.includes(bundle)) throw new Error(`--case names \`${key}\`: \`${bundle}\` is not a bundle under ${catalog.root} (bundles: ${catalog.bundles.join(', ')})`); + if (skills?.length && !skills.includes(bundle)) throw new Error(`--case names \`${key}\`, a case of \`${bundle}\`, which --skills leaves out (--skills: ${skills.join(', ')})`); + const inBundle = catalog.cases.filter((c) => c.bundle === bundle); + const stems = [...new Set(inBundle.map((c) => c.file.replace(/\.json$/, '')))]; + if (!stems.includes(stem)) throw new Error(`--case names \`${key}\`: ${bundle}/evals/ holds no eval file \`${stem}.json\` with a case (files: ${list(stems.map((s) => `${s}.json`))})`); + const ids = inBundle.filter((c) => c.file.replace(/\.json$/, '') === stem).map((c) => String(c.id)); + throw new Error(`--case names \`${key}\`: ${bundle}/evals/${stem}.json holds no case with id \`${id}\` (ids: ${ids.join(', ')})`); + } + const wanted = new Set(keys); + return selection.filter((c) => wanted.has(c.key)); +} diff --git a/packages/qa/scenarios/src/skill-evals/cli.ts b/packages/qa/scenarios/src/skill-evals/cli.ts index 3e8fff8d4d6..47740ed236d 100644 --- a/packages/qa/scenarios/src/skill-evals/cli.ts +++ b/packages/qa/scenarios/src/skill-evals/cli.ts @@ -4,7 +4,8 @@ * `pnpm --filter @objectstack/scenarios skill-evals` — run the published * skills' existing eval cases (`skills/BUNDLE/evals/*.json`) through the local * Claude Code login, each case on a with-skill and a no-skill arm, graded by - * the case's own `must_contain` / `must_not_contain`; a trigger case + * the case's own `must_contain` / `must_contain_any` / `must_not_contain` (an + * any-of group is met by any one of its tokens); a trigger case * (`should_trigger`) runs on the with-skill arm only, graded on whether the * turn loaded the bundle, and is reported beside them. A devx instrument run * from this checkout: not a CI job, not a merge gate, not in the package's @@ -17,6 +18,13 @@ * cases and bundles both come from SOURCE * --triggers-only only the selected bundles' trigger cases (`should_trigger`), on * the with-skill arm; refused beside --regrade or --self-test + * --case KEY[,KEY] only these cases, by the key the summary and each record print + * (`BUNDLE/FILE_STEM#ID`; ids repeat across a bundle's eval files): + * a behaviour case on both arms, a trigger case on the with-skill arm; + * repeatable. Beside --skills, every named case must be of a --skills + * bundle, and --skills still sets the competing set; refused beside + * --triggers-only (the keys already say which cases), --regrade or + * --self-test; `round.json` records the keys as `scope.selectedCases` * --trigger-field F what a trigger turn's project holds beside its bundle: `selection` * (default: every --skills bundle, or every bundle) or `own` (it alone, * as rounds recorded before); refused beside --regrade or --self-test @@ -49,7 +57,7 @@ import { dirname, join, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; import { armArgs, ARMS } from './arms.js'; -import { loadSkillEvalCatalog, selectBundles, type SkillEvalCatalog } from './cases.js'; +import { CASE_KEY_SHAPE, loadSkillEvalCatalog, selectBundles, selectCases, type SkillEvalCatalog, type SkillEvalCase } from './cases.js'; import { executeRound, planRound, preflight, regradeRecords, type RoundStop, runRecordFile, type SkillEvalRunRecord } from './run.js'; import { runSelfTest, selfTestReached } from './self-test.js'; import { renderSummaryMarkdown, type RoundSummary, summariseRound } from './summary.js'; @@ -73,6 +81,8 @@ export interface SkillEvalArgs { out?: string; regrade?: string; triggersOnly: boolean; + /** `--case`: the case keys (`BUNDLE/FILE_STEM#ID`) the round plans alone; absent ⇒ every case of the selected bundles. */ + cases?: string[]; /** `--trigger-field`; absent ⇒ `selection`. */ triggerField?: TriggerField; dryRun: boolean; @@ -117,6 +127,12 @@ export function parseSkillEvalArgs(argv: readonly string[]): SkillEvalArgs { else if (flag === '--out') a.out = val(); else if (flag === '--regrade') a.regrade = val(); else if (flag === '--triggers-only') a.triggersOnly = true; + else if (flag === '--case') { + const keys = val().split(',').map((s) => s.trim()).filter(Boolean); + const bad = keys.find((k) => !CASE_KEY_SHAPE.test(k)); + if (keys.length === 0 || bad !== undefined) throw new Error(`--case takes case keys \`BUNDLE/FILE_STEM#ID\`, comma-separated, as the summary and each record print them (\`objectstack-query/filters-pagination-search#3\`), not \`${bad ?? ''}\``); + a.cases = [...new Set([...(a.cases ?? []), ...keys])]; + } else if (flag === '--trigger-field') { const v = val(); if (!(TRIGGER_FIELDS as readonly string[]).includes(v)) throw new Error(`--trigger-field takes ${TRIGGER_FIELDS.join(' or ')}, not \`${v}\``); @@ -130,6 +146,9 @@ export function parseSkillEvalArgs(argv: readonly string[]): SkillEvalArgs { // Refused, never ignored: neither of these reads a selection the flag could narrow. if (a.triggersOnly && a.regrade !== undefined) throw new Error('--triggers-only cannot narrow --regrade: a regrade re-draws the recorded round at the scope it ran, so a --triggers-only round regrades as one without the flag'); if (a.triggersOnly && a.selfTest) throw new Error('--triggers-only cannot narrow --self-test: the self-test runs its own fixtures, never a selection of cases'); + if (a.cases && a.regrade !== undefined) throw new Error('--case cannot narrow --regrade: a regrade re-draws the recorded round at the scope it ran, and a round run with --case keeps its named cases'); + if (a.cases && a.selfTest) throw new Error('--case cannot narrow --self-test: the self-test runs its own fixtures, never a selection of cases'); + if (a.cases && a.triggersOnly) throw new Error('--case cannot be narrowed by --triggers-only: the keys already say which cases run, and a named trigger case runs on the with-skill arm alone'); if (a.triggerField && (a.regrade !== undefined || a.selfTest)) throw new Error(`--trigger-field cannot apply to ${a.selfTest ? '--self-test: the self-test runs its own fixtures' : '--regrade: a regrade runs no turn, and keeps the installed set its round recorded'}`); return a; } @@ -193,8 +212,11 @@ export interface RoundRecord { concurrency: number; maxUtilization: number; }; - /** `triggersOnly`: the round ran `--triggers-only` (its trigger cases alone, on the with-skill arm), and `--regrade` keeps that scope. */ - scope: { cases: number; arms: string[]; repeats: number; plannedTurns: number; ranTurns: number; notRunTurns: number; triggersOnly?: true }; + /** + * `triggersOnly`: the round ran `--triggers-only` (its trigger cases alone, on the with-skill arm), and `--regrade` keeps that scope. + * `selectedCases`: the round ran `--case`, and planned these case keys alone (catalog order); `--regrade` keeps them. Absent ⇒ every case of the bundles. + */ + scope: { cases: number; arms: string[]; repeats: number; plannedTurns: number; ranTurns: number; notRunTurns: number; triggersOnly?: true; selectedCases?: string[] }; /** What every trigger turn installed beside its bundle (`--trigger-field`); absent on a round recorded before ⇒ `own`. */ triggerField?: { mode: TriggerField; bundles?: string[] }; stopped?: RoundStop; @@ -240,10 +262,11 @@ export function writeRoundOutputs(outDir: string, round: RoundRecord): void { const { driver: d, scope } = round; const wallMin = Math.round(round.wallMs / 6000) / 10; const head = { - title: `Skill evals · ${round.skills.allBundles ? 'all bundles' : round.skills.bundles.join(', ')} × ${scope.triggersOnly ? 'trigger cases × the with-skill arm' : '2 arms'} × ${scope.repeats} rep${scope.repeats === 1 ? '' : 's'}`, + title: `Skill evals · ${scope.selectedCases ? `${scope.selectedCases.length} named case(s) of ${round.skills.bundles.join(', ')}` : round.skills.allBundles ? 'all bundles' : round.skills.bundles.join(', ')} × ${scope.triggersOnly ? 'trigger cases × the with-skill arm' : scope.arms.length === 1 ? 'the with-skill arm' : '2 arms'} × ${scope.repeats} rep${scope.repeats === 1 ? '' : 's'}`, lines: [ `runner: ${round.runner.repo} ${round.runner.sha}`, `skills: ${round.skills.source}`, + ...(scope.selectedCases ? [`cases: the ${scope.selectedCases.length} named by --case, alone: ${scope.selectedCases.map((k) => `\`${k}\``).join(', ')}`] : []), `driver: ${d.driver} ${d.version}, login \`${d.authMethod}\`, no API key; served ${d.servedModels.join(', ') || 'none'}; effort ${d.requestedEffort ?? 'CLI default'}`, `turns: ${scope.ranTurns} of ${scope.plannedTurns} ran (${turnsLine(round.summary.cases.length, round.summary.triggers?.cases.length ?? 0, scope.repeats)}), ${d.concurrency} at once, --max-turns ${d.maxTurns}`, `wall time: ${wallMin} min; notional cost the CLI reported: $${round.summary.reportedCostUsd} (subscription login, nothing billed)`, @@ -260,6 +283,19 @@ export function writeRoundOutputs(outDir: string, round: RoundRecord): void { console.log(`round: ${join(outDir, 'round.json')} · summary: ${join(outDir, 'summary.md')}`); } +/** + * The catalog's cases at the scope a recorded round planned: its bundles that + * are still in the catalog, narrowed as its `scope` says. A `--triggers-only` + * round planned its trigger cases alone and a `--case` round its named cases + * alone, so the rest of their bundles are not `added` since. Pure. + */ +export function roundCatalogCases(round: Pick, catalog: Pick): SkillEvalCase[] { + // The bundles may have left the catalog too; their cases are then set apart as removed. + const present = round.skills.bundles.filter((b) => catalog.bundles.includes(b)); + const named = round.scope.selectedCases ? new Set(round.scope.selectedCases) : undefined; + return catalog.cases.filter((c) => present.includes(c.bundle) && (!round.scope.triggersOnly || c.shouldTrigger !== undefined) && (!named || named.has(c.key))); +} + /** * `--regrade DIR`: re-draw every recorded turn's verdict under this runner's * rules from the answer and arm facts on its record (no login read, no model @@ -278,10 +314,7 @@ export function regradeRound(dir: string, catalog: SkillEvalCatalog, sourceLabel const round = JSON.parse(readFileSync(roundFile, 'utf8')) as RoundRecord; if (round.schema !== ROUND_RECORD_SCHEMA) throw new Error(`--regrade: ${roundFile} is not a \`${ROUND_RECORD_SCHEMA}\` record`); if (round.skills.source !== sourceLabel) throw new Error(`--regrade: the round ran on ${round.skills.source}, not ${sourceLabel}; pass the same --skills-from`); - // The bundles may have left the catalog too; their cases are then set apart as removed. - const present = round.skills.bundles.filter((b) => catalog.bundles.includes(b)); - // A `--triggers-only` round planned its trigger cases alone: its behaviour cases are not `added` since. - const catalogCases = present.length ? catalog.cases.filter((c) => present.includes(c.bundle) && (!round.scope.triggersOnly || c.shouldTrigger !== undefined)) : []; + const catalogCases = roundCatalogCases(round, catalog); const view = { bundles: catalog.bundles, unlisted: catalog.unlistedBundles }; const runsDir = join(dir, 'runs'); const files = readdirSync(runsDir).filter((n) => n.endsWith('.json')).sort(); @@ -309,7 +342,8 @@ export function regradeRound(dir: string, catalog: SkillEvalCatalog, sourceLabel const HELP = `skill-evals — run the published skills' eval cases on a with-skill and a no-skill arm pnpm --filter @objectstack/scenarios skill-evals [--skills a,b] [--skills-from workspace|VERSION] [--repeats N] [--concurrency N] [--max-turns N] [--case-timeout MIN] [--max-utilization F] [--model M] [--effort L] - [--bin PATH] [--out DIR] [--triggers-only] [--trigger-field selection|own] [--dry-run] [--regrade DIR] [--self-test] + [--bin PATH] [--out DIR] [--triggers-only | --case BUNDLE/FILE_STEM#ID[,…]] [--trigger-field selection|own] [--dry-run] + [--regrade DIR] [--self-test] See packages/qa/scenarios/README.md, "Running the published skills' eval cases".`; export async function main(argv: readonly string[]): Promise { @@ -342,7 +376,9 @@ export async function main(argv: readonly string[]): Promise { if (args.regrade) return regradeRound(resolve(args.regrade), catalog, source.label); // The competing set every trigger turn installs: the --skills bundles, or every bundle; `own` installs none beside. const triggerField = args.triggerField === 'own' ? undefined : [...new Set(args.skills?.length ? args.skills : catalog.bundles)]; - const cases = selectBundles(catalog, args.skills, args.triggersOnly, triggerField !== undefined); + const inBundles = selectBundles(catalog, args.skills, args.triggersOnly, triggerField !== undefined); + // `--case`: the named cases alone, each on the arms its kind takes (`planRound`). + const cases = args.cases ? selectCases(catalog, inBundles, args.cases, args.skills) : inBundles; const jobs = planRound(cases, args.repeats); const bundles = [...new Set(cases.map((c) => c.bundle))]; const turnOpts = { maxTurns: args.maxTurns, ...(args.model ? { model: args.model } : {}), ...(args.effort ? { effort: args.effort } : {}) }; @@ -353,9 +389,10 @@ export async function main(argv: readonly string[]): Promise { const triggers = cases.filter((c) => c.shouldTrigger !== undefined); for (const b of triggers.length ? (triggerField ?? []).filter((n) => !bundles.includes(n)) : []) console.log(` ${b}: no case selected; a competitor in every trigger turn`); console.log(`${turnsLine(cases.length - triggers.length, triggers.length, args.repeats)} = ${jobs.length} turn(s), ${args.concurrency} at once`); + if (args.cases) console.log(`--case: ${cases.length} named case(s) alone, of the ${inBundles.length} these bundles hold: ${cases.map((c) => c.key).join(', ')}`); if (args.triggersOnly) console.log(`--triggers-only: ${selectBundles(catalog, args.skills, false, triggerField !== undefined).length - cases.length} behaviour case(s) of these bundles left out`); if (triggers.length) console.log(`trigger cases: ${triggers.filter((c) => c.shouldTrigger).length} should load the bundle, ${triggers.filter((c) => !c.shouldTrigger).length} should not`); - console.log(`each turn: a fresh directory holding the case's files; with-skill also holds .claude/skills/BUNDLE/ (no evals/)${args.triggersOnly ? '' : ', no-skill no skill'}`); + console.log(`each turn: a fresh directory holding the case's files; with-skill also holds .claude/skills/BUNDLE/ (no evals/)${triggers.length === cases.length ? '' : ', no-skill no skill'}`); if (triggers.length) console.log(triggerField ? `each trigger turn installs ${triggerField.length} bundle(s) (--trigger-field selection): ${triggerField.join(', ')}` : 'each trigger turn installs its own bundle alone (--trigger-field own)'); console.log(`argv (prompt on stdin): ${args.bin} ${armArgs('TURN_DIR/mcp.json', turnOpts).join(' ')}`); console.log('dry run: no login read, no model called, nothing written'); @@ -396,7 +433,7 @@ export async function main(argv: readonly string[]): Promise { startedAt: startedAt.toISOString(), finishedAt: finishedAt.toISOString(), wallMs: finishedAt.getTime() - startedAt.getTime(), - skills: { source: source.label, bundles, allBundles: bundles.length === catalog.bundles.length }, + skills: { source: source.label, bundles, allBundles: !args.cases && bundles.length === catalog.bundles.length }, driver: { driver: 'claude-code-cli', version: pf.version, @@ -410,7 +447,17 @@ export async function main(argv: readonly string[]): Promise { concurrency: args.concurrency, maxUtilization: args.maxUtilization, }, - scope: { cases: cases.length, arms: args.triggersOnly ? ['with-skill'] : [...ARMS], repeats: args.repeats, plannedTurns: jobs.length, ranTurns: exec.records.length, notRunTurns: exec.notRun.length, ...(args.triggersOnly ? { triggersOnly: true as const } : {}) }, + scope: { + cases: cases.length, + // A `--case` round of trigger cases alone runs the with-skill arm alone. + arms: args.triggersOnly ? ['with-skill'] : args.cases ? ARMS.filter((arm) => jobs.some((j) => j.arm === arm)) : [...ARMS], + repeats: args.repeats, + plannedTurns: jobs.length, + ranTurns: exec.records.length, + notRunTurns: exec.notRun.length, + ...(args.triggersOnly ? { triggersOnly: true as const } : {}), + ...(args.cases ? { selectedCases: cases.map((c) => c.key) } : {}), + }, ...(triggerCount ? { triggerField: triggerField ? { mode: 'selection' as const, bundles: triggerField } : { mode: 'own' as const } } : {}), ...(exec.stopped ? { stopped: exec.stopped } : {}), summary: summariseRound(cases, exec.records, exec.notRun), diff --git a/packages/qa/scenarios/src/skill-evals/self-test.ts b/packages/qa/scenarios/src/skill-evals/self-test.ts index 75993bfc0ba..55b37bafa61 100644 --- a/packages/qa/scenarios/src/skill-evals/self-test.ts +++ b/packages/qa/scenarios/src/skill-evals/self-test.ts @@ -19,8 +19,8 @@ import { join } from 'node:path'; import { ApiBillingRefusedError } from '../runner/driver.js'; import { armArgs, placeCaseFiles, prepareArmWorkdir } from './arms.js'; -import { hashCase, loadSkillEvalCatalog, notUserInvocable, parseEvalFile, selectBundles, type SkillEvalCase } from './cases.js'; -import { parseSkillEvalArgs } from './cli.js'; +import { hashCase, loadSkillEvalCatalog, notUserInvocable, parseEvalFile, selectBundles, selectCases, type SkillEvalCase } from './cases.js'; +import { parseSkillEvalArgs, roundCatalogCases } from './cli.js'; import { type Grader, gradeAnswer } from './grade.js'; import { installedFor, judgeTurn, planRound, preflight, regradeRecords, type SkillEvalRunRecord } from './run.js'; import { renderSummaryMarkdown, summariseRound } from './summary.js'; @@ -67,10 +67,14 @@ export const SELF_TEST_BATTERIES = Object.freeze({ 'flags: --triggers-only beside --regrade or --self-test, or on a bundle with no trigger case → REFUSED': 1, 'judge: a should-load case where a neighbour bundle loaded instead of its own → FAIL, the neighbour named': 1, 'arms: a trigger turn installs the round\'s selection beside its bundle; --trigger-field own, its bundle alone': 1, + 'select: --case plans exactly the named cases, a behaviour case on both arms and a trigger case on the with-skill arm': 1, + 'select: --case naming an unknown bundle, eval file or id, or a bundle --skills leaves out → REFUSED with its location': 1, + 'flags: --case beside --regrade, --self-test or --triggers-only, or a key not shaped BUNDLE/FILE_STEM#ID → REFUSED': 1, + 'regrade: a --case round regrades at its named cases; the rest of their bundles are not "added since"': 1, }); /** The roster's own size, pinned: a deleted row takes its floor with it otherwise. */ -export const SELF_TEST_BATTERY_FLOOR = 40; +export const SELF_TEST_BATTERY_FLOOR = 44; let selfTestReachedVerdict = false; /** Whether the last {@link runSelfTest} reached its verdict line. */ @@ -550,6 +554,79 @@ export function runSelfTest(deps: SelfTestDeps): SelfTestResult { return ok ? true : `installed sets [${sets}], both bundles held: ${held}, --trigger-field own parsed: ${String(parsed)}, refusals: ${refused}, a caseless competitor kept: ${competes}`; }, }, + { + label: 'select: --case plans exactly the named cases, a behaviour case on both arms and a trigger case on the with-skill arm', + run: () => { + // Named out of catalog order and once twice: the plan keeps catalog order, each case once. + const keys = parseSkillEvalArgs(['--case', 'demo-skill/demo#2,demo-skill/demo#1', '--case', 'demo-skill/demo#2', '--dry-run']).cases ?? []; + const plan = (cases: SkillEvalCase[]) => planRound(cases, 1).map((j) => `${j.case.key}:${j.arm}`).join(); + const named = plan(selectCases(selectCatalog, selectBundles(selectCatalog, undefined), keys)); + // Beside --skills: a case of a --skills bundle, the other bundle's cases left out. + const skills = ['demo-skill', 'other-skill']; + const besideSkills = plan(selectCases(selectCatalog, selectBundles(selectCatalog, skills), ['other-skill/demo#1'], skills)); + const want = 'demo-skill/demo#1:with-skill,demo-skill/demo#1:no-skill,demo-skill/demo#2:with-skill'; + return named === want && besideSkills === 'other-skill/demo#1:with-skill,other-skill/demo#1:no-skill' + ? true + : `--case demo-skill/demo#2,demo-skill/demo#1 planned [${named}], expected [${want}]; beside --skills [${besideSkills}]`; + }, + }, + { + label: 'select: --case naming an unknown bundle, eval file or id, or a bundle --skills leaves out → REFUSED with its location', + run: () => { + const pool = selectBundles(selectCatalog, undefined); + const refusal = (keys: string[], why: RegExp, skills?: string[]) => { + try { + selectCases(selectCatalog, skills ? selectBundles(selectCatalog, skills) : pool, keys, skills); + } catch (e) { + const m = e instanceof Error ? e.message : String(e); + return why.test(m) ? '' : `[${keys.join()}] refused as "${m}"`; + } + return `[${keys.join()}] was not refused`; + }; + const wrong = [ + refusal(['demo-skill/demo#1', 'nope-skill/demo#1'], /`nope-skill\/demo#1`: `nope-skill` is not a bundle under fixture \(bundles: demo-skill, other-skill\)/), + refusal(['demo-skill/other#1'], /demo-skill\/evals\/ holds no eval file `other\.json` with a case \(files: `demo\.json`\)/), + refusal(['demo-skill/demo#9'], /demo-skill\/evals\/demo\.json holds no case with id `9` \(ids: 1, 2, 3\)/), + refusal(['other-skill/demo#1'], /a case of `other-skill`, which --skills leaves out/, ['demo-skill']), + ].filter(Boolean); + return wrong.length ? wrong.join('; ') : true; + }, + }, + { + label: 'flags: --case beside --regrade, --self-test or --triggers-only, or a key not shaped BUNDLE/FILE_STEM#ID → REFUSED', + run: () => { + const refusal = (argv: string[], why: RegExp) => { + try { + parseSkillEvalArgs(argv); + } catch (e) { + return why.test(e instanceof Error ? e.message : String(e)); + } + return false; + }; + const kept = parseSkillEvalArgs(['--case', 'demo-skill/demo#1', '--skills', 'demo-skill', '--trigger-field', 'own', '--dry-run']).cases?.join() === 'demo-skill/demo#1'; + const r = [ + refusal(['--case', 'demo-skill/demo#1', '--regrade', 'DIR'], /--case cannot narrow --regrade/), + refusal(['--self-test', '--case', 'demo-skill/demo#1'], /--case cannot narrow --self-test/), + refusal(['--triggers-only', '--case', 'demo-skill/demo#2'], /--case cannot be narrowed by --triggers-only/), + refusal(['--case', 'demo-skill:1'], /--case takes case keys `BUNDLE\/FILE_STEM#ID`.*not `demo-skill:1`/), + refusal(['--case', ','], /--case takes case keys/), + ]; + return kept && r.every(Boolean) ? true : `accepted beside --skills and --trigger-field: ${kept}; refused (--regrade, --self-test, --triggers-only, BUNDLE:ID, empty): ${r.join(', ')}`; + }, + }, + { + label: 'regrade: a --case round regrades at its named cases; the rest of their bundles are not "added since"', + run: () => { + const scope = { cases: 1, arms: ['with-skill'], repeats: 1, plannedTurns: 1, ranTurns: 1, notRunTurns: 0 }; + const skills = { source: 'fixture', bundles: ['demo-skill'], allBundles: false }; + const named = roundCatalogCases({ skills, scope: { ...scope, selectedCases: ['demo-skill/demo#2'] } }, selectCatalog); + const whole = roundCatalogCases({ skills, scope }, selectCatalog); + const added = regradeRecords([], ['demo-skill/demo#2'], named, { bundles: selectCatalog.bundles, unlisted: [] }).added; + return named.map((c) => c.key).join() === 'demo-skill/demo#2' && whole.length === 3 && added.length === 0 + ? true + : `a --case round's catalog cases [${named.map((c) => c.key).join()}], expected [demo-skill/demo#2]; without --case ${whole.length}, expected 3; added since [${added.join()}], expected none`; + }, + }, ]; let failed = 0; diff --git a/packages/qa/scenarios/src/skill-evals/summary.ts b/packages/qa/scenarios/src/skill-evals/summary.ts index fc6e3e1a0a5..a140deb643f 100644 --- a/packages/qa/scenarios/src/skill-evals/summary.ts +++ b/packages/qa/scenarios/src/skill-evals/summary.ts @@ -214,7 +214,7 @@ export function renderSummaryMarkdown(s: RoundSummary, head: { title: string; li out.push(`| **all** | ${s.cases.length} | ${pct(s.totals.withSkill)} | ${pct(s.totals.noSkill)} | ${s.bundles.reduce((n, b) => n + b.withSkillFailures.length, 0)} | ${s.bundles.reduce((n, b) => n + b.noSkillAtLeastWithSkill.length, 0)} | ${outOf(s.totals.withSkill)} / ${outOf(s.totals.noSkill)} |`); out.push('', '## Per case', '', '| case | with-skill | no-skill | with-skill missed | with-skill carried forbidden |', '|:--|--:|--:|:--|:--|'); for (const c of s.cases) { - // An unmet any-of group is named whole, after the all-of tokens: `(none of: a / b)`. + // An unmet any-of group is named whole, after the all-of tokens, each token a code span as theirs are: (none of: `a` / `b`). const missed = [...c.withSkillMissing.map(code), ...c.withSkillUnmetAny.map((g) => `(none of: ${g.map(code).join(' / ')})`)]; out.push(`| ${c.key} | ${pct(c.withSkill)} | ${pct(c.noSkill)} | ${missed.join(' ')} | ${c.withSkillForbidden.map(code).join(' ')} |`); } From 5b73c81b214a4e51ce51dc0328935fcf927ccab8 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 14:51:17 +0000 Subject: [PATCH 2/3] fix(qa): skill-evals --case dry-run line names where its case count comes from Claude-Session: https://claude.ai/code/session_016WV4cxBECSPtHxQMZDHSie Co-authored-by: Claude --- packages/qa/scenarios/src/skill-evals/cli.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/qa/scenarios/src/skill-evals/cli.ts b/packages/qa/scenarios/src/skill-evals/cli.ts index 47740ed236d..52cf4ad426d 100644 --- a/packages/qa/scenarios/src/skill-evals/cli.ts +++ b/packages/qa/scenarios/src/skill-evals/cli.ts @@ -389,7 +389,7 @@ export async function main(argv: readonly string[]): Promise { const triggers = cases.filter((c) => c.shouldTrigger !== undefined); for (const b of triggers.length ? (triggerField ?? []).filter((n) => !bundles.includes(n)) : []) console.log(` ${b}: no case selected; a competitor in every trigger turn`); console.log(`${turnsLine(cases.length - triggers.length, triggers.length, args.repeats)} = ${jobs.length} turn(s), ${args.concurrency} at once`); - if (args.cases) console.log(`--case: ${cases.length} named case(s) alone, of the ${inBundles.length} these bundles hold: ${cases.map((c) => c.key).join(', ')}`); + if (args.cases) console.log(`--case: ${cases.length} named case(s) alone, of the ${inBundles.length} ${args.skills?.length ? 'the --skills bundles hold' : 'in the catalog'}: ${cases.map((c) => c.key).join(', ')}`); if (args.triggersOnly) console.log(`--triggers-only: ${selectBundles(catalog, args.skills, false, triggerField !== undefined).length - cases.length} behaviour case(s) of these bundles left out`); if (triggers.length) console.log(`trigger cases: ${triggers.filter((c) => c.shouldTrigger).length} should load the bundle, ${triggers.filter((c) => !c.shouldTrigger).length} should not`); console.log(`each turn: a fresh directory holding the case's files; with-skill also holds .claude/skills/BUNDLE/ (no evals/)${triggers.length === cases.length ? '' : ', no-skill no skill'}`); From c6ffc0b81395dfa7008fcf2de3c1c042498c7888 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 14:57:37 +0000 Subject: [PATCH 3/3] chore(changeset): @objectstack/scenarios patch for skill-evals --case Claude-Session: https://claude.ai/code/session_016WV4cxBECSPtHxQMZDHSie Co-authored-by: Claude --- .changeset/37980-skill-evals-case-filter.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .changeset/37980-skill-evals-case-filter.md diff --git a/.changeset/37980-skill-evals-case-filter.md b/.changeset/37980-skill-evals-case-filter.md new file mode 100644 index 00000000000..f35ecd2d7cc --- /dev/null +++ b/.changeset/37980-skill-evals-case-filter.md @@ -0,0 +1,10 @@ +--- +'@objectstack/scenarios': patch +--- + +feat(scenarios): `skill-evals --case BUNDLE/FILE_STEM#ID[,…]` plans the named eval cases alone, so a single-case acceptance round runs from the committed command + +Clause-②: no +Metadata-protocol: none + +The skill-evals runner selected whole bundles (`--skills`, `--skills-from`, `--triggers-only`) and never one case, so a round on one case needed a driver of its own. `--case` takes case keys as the summary and every run record print them (`objectstack-ai/skills-tools-knowledge#6`): ids repeat across a bundle's eval files, so a bundle and an id alone would not name one case. The round plans only those cases, a behaviour case on both arms and a trigger case on the with-skill arm. A key that names no case is refused with where it stopped matching (the bundle, the eval file or the id, and the ones that exist). Beside `--skills`, every named case must be of a `--skills` bundle, and `--skills` still sets what a trigger turn installs; the flag is refused beside `--triggers-only`, `--regrade` and `--self-test`. `round.json` gains `scope.selectedCases` (additive; absent on every other round), the summary header lists the keys, and `--regrade DIR` keeps that scope instead of reading the rest of the bundle as cases added since. The runner's header comment and README now name the `must_contain_any` form, and the README shows the summary's unmet-group form as the renderer prints it, each token in a code span.