From 6a6a9e8a625f3cab7631dc3692d403cae08302dc Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 21:32:50 +0000 Subject: [PATCH 1/5] wip(scenarios): skill-evals reads trigger cases and case files Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX --- packages/qa/scenarios/src/skill-evals/arms.ts | 13 ++ .../qa/scenarios/src/skill-evals/cases.ts | 119 +++++++++++++++--- packages/qa/scenarios/src/skill-evals/cli.ts | 28 +++-- packages/qa/scenarios/src/skill-evals/run.ts | 81 ++++++++++-- .../qa/scenarios/src/skill-evals/summary.ts | 96 +++++++++++++- 5 files changed, 302 insertions(+), 35 deletions(-) diff --git a/packages/qa/scenarios/src/skill-evals/arms.ts b/packages/qa/scenarios/src/skill-evals/arms.ts index a475edebc84..c1b2eafa000 100644 --- a/packages/qa/scenarios/src/skill-evals/arms.ts +++ b/packages/qa/scenarios/src/skill-evals/arms.ts @@ -97,3 +97,16 @@ export function prepareArmWorkdir(arm: Arm, bundle: string, skillsRoot: string, } return { cwd, mcpConfigPath, root }; } + +/** + * Place a case's `files` in a turn's project: each entry, a path under the + * bundle's `evals/files/` (the reader has refused any other), is copied to the + * same path below `evals/files/` inside `cwd`, a directory whole. Called for + * both arms alike, so the arms still differ only in the bundle. + */ +export function placeCaseFiles(files: readonly string[] | undefined, bundle: string, skillsRoot: string, cwd: string): void { + for (const f of files ?? []) { + const below = f.split('/').slice(2).join('/'); + cpSync(join(skillsRoot, bundle, f), join(cwd, below), { recursive: true, dereference: true }); + } +} diff --git a/packages/qa/scenarios/src/skill-evals/cases.ts b/packages/qa/scenarios/src/skill-evals/cases.ts index 9466555b2db..37f04b9e38c 100644 --- a/packages/qa/scenarios/src/skill-evals/cases.ts +++ b/packages/qa/scenarios/src/skill-evals/cases.ts @@ -9,11 +9,27 @@ * { "skill_name": BUNDLE, "evals": [ { "id", "prompt", "expected_output", * "files": [], "assertions": { "must_contain": [..], "must_not_contain": [..] } } ] } * + * A TRIGGER case asks the other question about a skill: was it loaded when + * it should be, and left alone when it should not. It is the same entry with + * `"should_trigger": true | false` in place of `assertions`, and it is graded + * on whether the with-skill turn loaded the bundle, never on its answer: + * + * { "id", "prompt", "should_trigger": false, "files": [] } + * + * `files` names what a case needs on disk: each entry is a path under the + * bundle's `evals/files/` (`"evals/files/src/objects/task.object.ts"`), a file + * or a directory, placed in the turn's working directory at the path below + * `evals/files/` on both arms. `evals/` itself is never copied into a turn, so + * a case's files reach it only this way. + * * The reader is strict, never lenient: a file that does not parse, a case * whose prompt is not a string, an assertion list that is not a list of - * strings, or a case with no assertion at all is a located refusal — never a - * case graded as a pass because nothing was asked of it. The cases themselves - * are not this runner's to edit. + * strings, a case with no assertion at all, a trigger case that also carries + * assertions, a `files` entry outside `evals/files/` or missing from it, and a + * bundle whose trigger cases are all of one kind (all positive cannot show a + * false load; all negative cannot show a missed one) are located refusals — + * never a case graded as a pass because nothing was asked of it. The cases + * themselves are not this runner's to edit. */ import { createHash } from 'node:crypto'; @@ -34,6 +50,14 @@ export interface SkillEvalCase { expectedOutput?: string; mustContain: string[]; mustNotContain: string[]; + /** + * Set ⇒ a trigger case: graded on whether the with-skill turn loaded the + * bundle (`true`: it should; `false`: it should not), on that arm only. Its + * token lists are empty. + */ + shouldTrigger?: boolean; + /** Paths under the bundle's `evals/files/` placed in the turn's project; absent ⇒ none. */ + files?: string[]; } /** A file or case the reader refused, with where. */ @@ -66,11 +90,33 @@ export const caseKey = (bundle: string, file: string, id: number | string): stri /** * The case as a turn meets it: a hash of the prompt the turn is asked and the * two token lists its answer is graded on (`expected_output` is neither sent - * nor graded, so it is left out). Every run record carries it, so `--regrade` - * can tell a case reworded since the round from the case that ran. Pure. + * nor graded, so it is left out), and, only when the case has them, its + * trigger kind and its `files` list (names, not contents) — so a behaviour + * case with no files hashes as it did before either existed. Every run record + * carries it, so `--regrade` can tell a case reworded since the round from the + * case that ran. Pure. */ -export const hashCase = (c: Pick): string => - `sha256:${createHash('sha256').update(JSON.stringify([c.prompt, c.mustContain, c.mustNotContain])).digest('hex')}`; +export const hashCase = (c: Pick): string => { + const extra = { + ...(c.shouldTrigger !== undefined ? { shouldTrigger: c.shouldTrigger } : {}), + ...(c.files?.length ? { files: c.files } : {}), + }; + const parts: unknown[] = [c.prompt, c.mustContain, c.mustNotContain]; + if (Object.keys(extra).length) parts.push(extra); + return `sha256:${createHash('sha256').update(JSON.stringify(parts)).digest('hex')}`; +}; + +/** The directory under a bundle that holds the files cases place in a turn's project. */ +export const CASE_FILES_DIR = 'evals/files'; + +/** Why a `files` entry is refused; `undefined` ⇒ it names a path under `evals/files/`. Pure. */ +export function caseFileProblem(entry: string): string | undefined { + const parts = entry.split('/'); + if (entry.includes('\\') || parts.length < 3 || `${parts[0]}/${parts[1]}` !== CASE_FILES_DIR || parts.slice(2).some((p) => p === '' || p === '.' || p === '..')) { + return `\`files\` entry \`${entry}\` is not a path under \`${CASE_FILES_DIR}/\` (forward slashes, no \`.\` or \`..\` segment)`; + } + return undefined; +} /** Read one eval file's text into cases, or refusals. Pure over its inputs. */ export function parseEvalFile(bundle: string, file: string, text: string): { cases: SkillEvalCase[]; refusals: SkillEvalRefusal[] } { @@ -102,19 +148,45 @@ export function parseEvalFile(bundle: string, file: string, text: string): { cas refusals.push({ path: at, message: '`prompt` is not a non-empty string' }); return; } - const a = e.assertions; - if (typeof a !== 'object' || a === null || Array.isArray(a)) { - refusals.push({ path: at, message: '`assertions` is not an object' }); + const files = e.files ?? []; + if (!isStringList(files)) { + refusals.push({ path: at, message: '`files` must be a list of strings' }); return; } - const { must_contain: mc = [], must_not_contain: mnc = [] } = a as Record; - if (!isStringList(mc) || !isStringList(mnc)) { - refusals.push({ path: at, message: '`assertions.must_contain` / `must_not_contain` must each be a list of strings' }); + const badFile = files.map(caseFileProblem).find((m) => m !== undefined); + if (badFile) { + refusals.push({ path: at, message: badFile }); return; } - if (mc.length + mnc.length === 0) { - refusals.push({ path: at, message: 'asserts nothing: a case with no `must_contain` and no `must_not_contain` would pass every answer' }); - return; + let mc: string[] = []; + let mnc: string[] = []; + const trigger = e.should_trigger; + if (trigger !== undefined) { + if (typeof trigger !== 'boolean') { + refusals.push({ path: at, message: '`should_trigger` is neither `true` nor `false`' }); + return; + } + if (e.assertions !== undefined) { + refusals.push({ path: at, message: 'is a trigger case (`should_trigger`) and carries `assertions`: a trigger case is graded on whether the skill was loaded, never on its answer' }); + return; + } + } else { + const a = e.assertions; + if (typeof a !== 'object' || a === null || Array.isArray(a)) { + refusals.push({ path: at, message: '`assertions` is not an object' }); + return; + } + const { must_contain: rawMc = [], must_not_contain: rawMnc = [] } = a as Record; + if (!isStringList(rawMc) || !isStringList(rawMnc)) { + refusals.push({ path: at, message: '`assertions.must_contain` / `must_not_contain` must each be a list of strings' }); + return; + } + if (rawMc.length + rawMnc.length === 0) { + refusals.push({ path: at, message: 'asserts nothing: a case with no `must_contain` and no `must_not_contain` would pass every answer' }); + return; + } + mc = rawMc; + mnc = rawMnc; } const key = caseKey(bundle, file, id); if (seen.has(key)) { @@ -131,6 +203,8 @@ export function parseEvalFile(bundle: string, file: string, text: string): { cas ...(typeof e.expected_output === 'string' ? { expectedOutput: e.expected_output } : {}), mustContain: mc, mustNotContain: mnc, + ...(typeof trigger === 'boolean' ? { shouldTrigger: trigger } : {}), + ...(files.length ? { files } : {}), }); }); return { cases, refusals }; @@ -154,11 +228,22 @@ export function loadSkillEvalCatalog(root: string): SkillEvalCatalog { .filter((d) => d.isFile() && d.name.endsWith('.json')) .map((d) => d.name) .sort(); + const mine: SkillEvalCase[] = []; for (const file of files) { const r = parseEvalFile(bundle, file, readFileSync(join(dir, file), 'utf8')); - cases.push(...r.cases); + for (const c of r.cases) { + const missingFile = (c.files ?? []).find((f) => !existsSync(join(root, bundle, f))); + if (missingFile) refusals.push({ path: `${bundle}/evals/${file}: ${c.key}`, message: `\`files\` names \`${missingFile}\`, which is not in the bundle` }); + else mine.push(c); + } refusals.push(...r.refusals); } + const kinds = new Set(mine.filter((c) => c.shouldTrigger !== undefined).map((c) => c.shouldTrigger)); + if (kinds.size === 1) { + const only = kinds.has(true) ? 'positive' : 'negative'; + refusals.push({ path: `${bundle}/evals`, message: `every trigger case is ${only}: a trigger set needs at least one \`should_trigger: true\` and one \`false\`, or it cannot show a ${only === 'positive' ? 'false load' : 'missed load'}` }); + } + cases.push(...mine); } const unlistedBundles = bundles.filter((b) => notUserInvocable(readFileSync(join(root, b, 'SKILL.md'), 'utf8'))); return { root, bundles, unlistedBundles, cases, refusals }; diff --git a/packages/qa/scenarios/src/skill-evals/cli.ts b/packages/qa/scenarios/src/skill-evals/cli.ts index 9669e9a47b3..f14b5147df5 100644 --- a/packages/qa/scenarios/src/skill-evals/cli.ts +++ b/packages/qa/scenarios/src/skill-evals/cli.ts @@ -4,7 +4,9 @@ * `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 devx instrument run + * the case's own `must_contain` / `must_not_contain`; 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 * published `bin` or `exports`. README section "Running the published skills' * eval cases" is the operator's page. @@ -198,7 +200,11 @@ export function regradedLines(g: NonNullable): string[] ]; } -/** `round.json`, `summary.md` and `summary.github.md` into `outDir`, and the per-bundle table on stdout. */ +/** `N behaviour case(s) × 2 arms [+ M trigger case(s) × the with-skill arm], × R`. Pure. */ +export const turnsLine = (behaviour: number, trigger: number, repeats: number): string => + `${behaviour} behaviour case(s) × ${ARMS.length} arms${trigger ? ` + ${trigger} trigger case(s) × the with-skill arm` : ''}, × ${repeats}`; + +/** `round.json`, `summary.md` and `summary.github.md` into `outDir`, and the per-bundle tables on stdout. */ export function writeRoundOutputs(outDir: string, round: RoundRecord): void { writeFileSync(join(outDir, 'round.json'), JSON.stringify(round, null, 2) + '\n'); const { driver: d, scope } = round; @@ -209,7 +215,7 @@ export function writeRoundOutputs(outDir: string, round: RoundRecord): void { `runner: ${round.runner.repo} ${round.runner.sha}`, `skills: ${round.skills.source}`, `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 (${scope.cases} cases × 2 arms × ${scope.repeats}), ${d.concurrency} at once, --max-turns ${d.maxTurns}`, + `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)`, ...(round.regraded ? regradedLines(round.regraded) : []), ], @@ -217,7 +223,9 @@ export function writeRoundOutputs(outDir: string, round: RoundRecord): void { }; writeFileSync(join(outDir, 'summary.md'), renderSummaryMarkdown(round.summary, head)); writeFileSync(join(outDir, 'summary.github.md'), renderSummaryMarkdown(round.summary, head, { forGitHub: true })); - console.log(`\n${renderSummaryMarkdown(round.summary, head).split('## Per case')[0]}`); + const md = renderSummaryMarkdown(round.summary, head); + const triggerTable = md.includes('\n## Trigger cases') ? md.slice(md.indexOf('\n## Trigger cases')).split('\n| trigger case |')[0] : ''; + console.log(`\n${md.split('## Per case')[0]}${triggerTable}`); console.log(`round: ${join(outDir, 'round.json')} · summary: ${join(outDir, 'summary.md')}`); } @@ -248,7 +256,8 @@ export function regradeRound(dir: string, catalog: SkillEvalCatalog, sourceLabel const recorded = files.map((f) => ({ f, rec: JSON.parse(readFileSync(join(runsDir, f), 'utf8')) as SkillEvalRunRecord })); // The cases the round planned: its summary's, plus any an earlier regrade set apart (and so left out of it). const before = round.regraded?.setApart; - const plannedKeys = [...new Set([...round.summary.cases.map((c) => c.key), ...(before?.changed ?? []), ...(before?.removed ?? [])])]; + // A round recorded before trigger cases existed has no `triggers`. + const plannedKeys = [...new Set([...round.summary.cases.map((c) => c.key), ...(round.summary.triggers?.cases ?? []).map((c) => c.key), ...(before?.changed ?? []), ...(before?.removed ?? [])])]; const out = regradeRecords(recorded.map((r) => r.rec), plannedKeys, catalogCases, view); const byKey = new Map(out.cases.map((c) => [c.key, c])); const regraded = new Map(out.records.map((r) => [`${r.key}|${r.arm}|${r.repeat}`, r])); @@ -307,8 +316,10 @@ export async function main(argv: readonly string[]): Promise { if (args.dryRun) { console.log(`skills: ${source.label} (${source.root})`); for (const b of bundles) console.log(` ${b}: ${cases.filter((c) => c.bundle === b).length} case(s)`); - console.log(`${cases.length} case(s) × ${ARMS.length} arms × ${args.repeats} repeat(s) = ${jobs.length} turn(s), ${args.concurrency} at once`); - console.log(`each turn: a fresh directory; with-skill holds .claude/skills/BUNDLE/ (no evals/), no-skill holds nothing`); + const triggers = cases.filter((c) => c.shouldTrigger !== undefined); + console.log(`${turnsLine(cases.length - triggers.length, triggers.length, args.repeats)} = ${jobs.length} turn(s), ${args.concurrency} at once`); + 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/), no-skill no skill`); 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'); return 0; @@ -322,7 +333,8 @@ export async function main(argv: readonly string[]): Promise { const outDir = resolve(args.out ?? join(repo, 'docs', 'qa', 'platform-checklist', 'runs', 'skill-evals', roundId)); mkdirSync(outDir, { recursive: true }); if (existsSync(join(outDir, 'round.json'))) throw new Error(`${outDir} already holds a round.json: pass a fresh --out`); - console.log(`skill-evals: ${jobs.length} turn(s) (${cases.length} case(s) × ${ARMS.length} arms × ${args.repeats}), ${args.concurrency} at once, ${pf.version}, login ${pf.authMethod}`); + const triggerCount = cases.filter((c) => c.shouldTrigger !== undefined).length; + console.log(`skill-evals: ${jobs.length} turn(s) (${turnsLine(cases.length - triggerCount, triggerCount, args.repeats)}), ${args.concurrency} at once, ${pf.version}, login ${pf.authMethod}`); console.log(`records: ${outDir}`); const exec = await executeRound(jobs, { diff --git a/packages/qa/scenarios/src/skill-evals/run.ts b/packages/qa/scenarios/src/skill-evals/run.ts index b48c96277b2..64d2bab77d3 100644 --- a/packages/qa/scenarios/src/skill-evals/run.ts +++ b/packages/qa/scenarios/src/skill-evals/run.ts @@ -13,7 +13,10 @@ * What a turn's record can say: * * - `pass` / `fail` — the answer (the result line's text, the reply the asker - * reads) against the case's tokens; + * reads) against the case's tokens; for a trigger case, whether the turn + * loaded the bundle (a `Skill` launch of it, or a `Read` of a file under its + * `.claude/skills/BUNDLE/`) against `should_trigger`. A trigger case runs on + * the with-skill arm only: without the bundle nothing can be loaded; * - `invalid` — the turn did not run the arm it was meant to: the with-skill * arm's init line does not list the bundle, or the no-skill arm's lists a * bundle of the catalog. Out of the denominator, and counted; @@ -35,7 +38,7 @@ import { assertSubscriptionLogin, CLAUDE_EFFORT_ENV, effortLevelsFromHelp, subsc import { runTurnProcess, type TurnProcessRun } from '../runner/drivers/process.js'; import { parseStreamJson } from '../runner/transcript.js'; import type { TurnProcess } from '../runner/transcript.js'; -import { ARMS, type Arm, armArgs, prepareArmWorkdir } from './arms.js'; +import { ARMS, type Arm, armArgs, placeCaseFiles, prepareArmWorkdir } from './arms.js'; import { hashCase, type SkillEvalCase } from './cases.js'; import { type Grader, gradeAnswer } from './grade.js'; @@ -50,6 +53,15 @@ export type RunVerdict = 'pass' | 'fail' | 'invalid' | 'error'; */ export type ArmEvidence = 'init-line' | 'launched' | 'not-shown'; +/** How a turn reached a bundle's text: a `Skill` launch of it, or a `Read` of a file under it. */ +export type LoadEvidence = 'skill-tool' | 'read'; + +/** A trigger case's reading: what it asked, and how the turn reached the bundle (empty ⇒ it did not). */ +export interface TriggerReading { + shouldTrigger: boolean; + loadedBy: LoadEvidence[]; +} + export interface RateLimitReading { status?: string; rateLimitType?: string; @@ -65,6 +77,12 @@ export interface TurnStreamFacts { initSkills?: string[]; /** The `skill` input of every `Skill` tool call. */ skillsInvoked: string[]; + /** + * Every file a `Read` call named under a `.claude/skills/` directory, as the + * path below it (`objectstack-data/SKILL.md`): the turn reading a skill's + * text instead of launching it. + */ + skillFilesRead: string[]; /** The result line's `permission_denials` count. */ permissionDenials?: number; /** The tool each of those denials refused, in order. */ @@ -73,9 +91,12 @@ export interface TurnStreamFacts { rateLimit?: RateLimitReading; } +/** A path under a project's `.claude/skills/`, captured below it. */ +const SKILL_FILE_PATH = /(?:^|\/)\.claude\/skills\/(.+)$/; + /** Read the facts {@link parseStreamJson} does not keep. Pure over its input. */ export function readStreamFacts(stdout: string): TurnStreamFacts { - const facts: TurnStreamFacts = { skillsInvoked: [] }; + const facts: TurnStreamFacts = { skillsInvoked: [], skillFilesRead: [] }; for (const line of stdout.split('\n')) { const t = line.trim(); if (!t.startsWith('{')) continue; @@ -108,6 +129,10 @@ export function readStreamFacts(stdout: string): TurnStreamFacts { if (b?.type === 'tool_use' && b.name === 'Skill' && typeof b.input === 'object' && b.input !== null) { const skill = (b.input as Record).skill; if (typeof skill === 'string') facts.skillsInvoked.push(skill); + } else if (b?.type === 'tool_use' && b.name === 'Read' && typeof b.input === 'object' && b.input !== null) { + const path = (b.input as Record).file_path; + const below = typeof path === 'string' ? SKILL_FILE_PATH.exec(path.replace(/\\/g, '/')) : null; + if (below) facts.skillFilesRead.push(below[1]!); } } } @@ -147,6 +172,10 @@ export interface SkillEvalRunRecord { bundlesLoaded: string[]; /** Every skill the turn launched with the `Skill` tool. */ skillsInvoked: string[]; + /** Files the turn read under `.claude/skills/` (absent on a record written before the runner kept them). */ + skillFilesRead?: string[]; + /** A trigger case's reading: whether the turn loaded the bundle, and how. */ + trigger?: TriggerReading; /** The tools the turn called, in order. */ toolCalls: string[]; permissionDenials?: number; @@ -180,6 +209,8 @@ export interface VerdictFacts { initSeen: boolean; bundlesLoaded: readonly string[]; skillsInvoked: readonly string[]; + /** Absent on a record written before the runner kept it: read as none. */ + skillFilesRead?: readonly string[]; resultSubtype?: string; answer?: string; } @@ -190,6 +221,18 @@ export interface Verdict { missing: string[]; forbidden: string[]; armEvidence?: ArmEvidence; + trigger?: TriggerReading; +} + +/** The arms a case runs on: both, or the with-skill arm alone for a trigger case. Pure. */ +export const armsOf = (c: Pick): readonly Arm[] => (c.shouldTrigger === undefined ? ARMS : ['with-skill']); + +/** How the turn reached `bundle`'s text, in a fixed order; empty ⇒ it did not. Pure. */ +export function loadEvidence(bundle: string, f: Pick): LoadEvidence[] { + const by: LoadEvidence[] = []; + if (f.skillsInvoked.includes(bundle)) by.push('skill-tool'); + if ((f.skillFilesRead ?? []).some((p) => p.startsWith(`${bundle}/`))) by.push('read'); + return by; } /** @@ -200,6 +243,13 @@ export interface Verdict { * its answer, with `armEvidence` saying whether the turn launched it; a listed * bundle absent from the line is `invalid`. The no-skill arm is `invalid` when * its init line lists a catalog bundle or it launches one. + * + * A trigger case is judged on {@link loadEvidence}, not on its answer: `pass` + * when the turn loaded the bundle exactly when `shouldTrigger` says it should. + * A turn that loaded it is judged however it ended (the load already + * happened); one that did not is judged only when it ended `success`, since a + * turn cut short may have been about to load it. On the no-skill arm it is + * `invalid`: nothing there can be loaded. */ export function verdictOf(c: SkillEvalCase, arm: Arm, f: VerdictFacts, catalog: CatalogView, grade: Grader = gradeAnswer): Verdict { const none = { missing: [], forbidden: [] }; @@ -208,6 +258,7 @@ export function verdictOf(c: SkillEvalCase, arm: Arm, f: VerdictFacts, catalog: return { verdict: 'error', reason: p.error ? `the process failed: ${p.error}` : p.timedOut ? `killed by the ${p.timeoutMs} ms case timeout` : `the CLI exited ${String(p.exit)}${p.signal ? ` (${p.signal})` : ''}`, ...none }; } if (!f.initSeen) return { verdict: 'error', reason: NO_INIT_LINE, ...none }; + if (c.shouldTrigger !== undefined && arm !== 'with-skill') return { verdict: 'invalid', reason: 'a trigger case runs on the with-skill arm only', ...none }; let armEvidence: ArmEvidence | undefined; if (arm === 'with-skill') { if (f.bundlesLoaded.includes(c.bundle)) armEvidence = 'init-line'; @@ -219,6 +270,14 @@ export function verdictOf(c: SkillEvalCase, arm: Arm, f: VerdictFacts, catalog: if (launched.length > 0) return { verdict: 'invalid', reason: `the no-skill turn launched ${launched.map((b) => `\`${b}\``).join(', ')}`, ...none }; } const ev = armEvidence ? { armEvidence } : {}; + if (c.shouldTrigger !== undefined) { + const trigger: TriggerReading = { shouldTrigger: c.shouldTrigger, loadedBy: loadEvidence(c.bundle, f) }; + const loaded = trigger.loadedBy.length > 0; + if (!loaded && f.resultSubtype !== 'success') { + return { verdict: 'error', reason: `the turn ended \`${f.resultSubtype ?? 'absent'}\` without loading the bundle, so not loading it is not shown`, ...none, ...ev, trigger }; + } + return { verdict: loaded === c.shouldTrigger ? 'pass' : 'fail', ...none, ...ev, trigger }; + } if (f.resultSubtype !== 'success' || f.answer === undefined) { return { verdict: 'error', reason: `no answer to grade: the result line is \`${f.resultSubtype ?? 'absent'}\``, ...none, ...ev }; } @@ -233,6 +292,7 @@ const applyVerdict = (base: T, v: Verdict) => ({ missing: v.missing, forbidden: v.forbidden, ...(v.armEvidence ? { armEvidence: v.armEvidence } : {}), + ...(v.trigger ? { trigger: v.trigger } : {}), }); /** Judge one finished turn. Pure over its inputs. */ @@ -259,6 +319,7 @@ export function judgeTurn( caseHash: hashCase(c), bundlesLoaded, skillsInvoked: facts.skillsInvoked, + skillFilesRead: facts.skillFilesRead, toolCalls: turn.toolCalls.map((t) => t.rawName), ...(facts.permissionDenials !== undefined ? { permissionDenials: facts.permissionDenials } : {}), ...(facts.deniedTools?.length ? { deniedTools: facts.deniedTools } : {}), @@ -272,7 +333,7 @@ export function judgeTurn( startedAt, ...(facts.answer !== undefined ? { answer: facts.answer } : {}), } as const; - const v = verdictOf(c, arm, { process: run.process, initSeen: facts.initSkills !== undefined, bundlesLoaded, skillsInvoked: facts.skillsInvoked, ...(turn.meta.resultSubtype ? { resultSubtype: turn.meta.resultSubtype } : {}), ...(facts.answer !== undefined ? { answer: facts.answer } : {}) }, catalog, grade); + const v = verdictOf(c, arm, { process: run.process, initSeen: facts.initSkills !== undefined, bundlesLoaded, skillsInvoked: facts.skillsInvoked, skillFilesRead: facts.skillFilesRead, ...(turn.meta.resultSubtype ? { resultSubtype: turn.meta.resultSubtype } : {}), ...(facts.answer !== undefined ? { answer: facts.answer } : {}) }, catalog, grade); return applyVerdict(base, v); } @@ -299,8 +360,8 @@ export function caseDrift(rec: Pick, c: SkillEva */ export function regradeRecord(rec: SkillEvalRunRecord, c: SkillEvalCase, catalog: CatalogView, grade: Grader = gradeAnswer): SkillEvalRunRecord { if (caseDrift(rec, c) === 'changed') throw new Error(`--regrade: \`${rec.key}\` has changed since the turn ran (record ${rec.caseHash}, now ${hashCase(c)}); a changed case is set apart, never regraded`); - const { reason: _reason, armEvidence: _ev, regradedFrom: _was, ...rest } = rec; - const v = verdictOf(c, rec.arm, { process: rec.process, initSeen: rec.reason !== NO_INIT_LINE, bundlesLoaded: rec.bundlesLoaded, skillsInvoked: rec.skillsInvoked, ...(rec.resultSubtype ? { resultSubtype: rec.resultSubtype } : {}), ...(rec.answer !== undefined ? { answer: rec.answer } : {}) }, catalog, grade); + const { reason: _reason, armEvidence: _ev, regradedFrom: _was, trigger: _trigger, ...rest } = rec; + const v = verdictOf(c, rec.arm, { process: rec.process, initSeen: rec.reason !== NO_INIT_LINE, bundlesLoaded: rec.bundlesLoaded, skillsInvoked: rec.skillsInvoked, ...(rec.skillFilesRead ? { skillFilesRead: rec.skillFilesRead } : {}), ...(rec.resultSubtype ? { resultSubtype: rec.resultSubtype } : {}), ...(rec.answer !== undefined ? { answer: rec.answer } : {}) }, catalog, grade); const out = applyVerdict(rest, v); const asRun = rec.regradedFrom ?? rec.verdict; return v.verdict === asRun ? out : { ...out, regradedFrom: asRun }; @@ -416,10 +477,13 @@ export interface RoundJob { repeat: number; } -/** The turns of a round, case-major with both arms adjacent, so a stopped round still holds paired arms. */ +/** + * The turns of a round, case-major with both arms adjacent, so a stopped round + * still holds paired arms; a trigger case takes the with-skill arm only. + */ export function planRound(cases: readonly SkillEvalCase[], repeats: number): RoundJob[] { const jobs: RoundJob[] = []; - for (let r = 1; r <= repeats; r++) for (const c of cases) for (const arm of ARMS) jobs.push({ case: c, arm, repeat: r }); + for (let r = 1; r <= repeats; r++) for (const c of cases) for (const arm of armsOf(c)) jobs.push({ case: c, arm, repeat: r }); return jobs; } @@ -483,6 +547,7 @@ export async function executeRound(jobs: readonly RoundJob[], opts: RoundOptions const dir = prepareArmWorkdir(job.arm, job.case.bundle, opts.skillsRoot); const startedAt = new Date().toISOString(); try { + placeCaseFiles(job.case.files, job.case.bundle, opts.skillsRoot, dir.cwd); const run = await runTurn(opts.bin, armArgs(dir.mcpConfigPath, opts), { cwd: dir.cwd, input: job.case.prompt, timeoutMs: opts.caseTimeoutMs, env }); const rec = judgeTurn(job.case, job.arm, job.repeat, run, opts.catalog, startedAt); records.push(rec); diff --git a/packages/qa/scenarios/src/skill-evals/summary.ts b/packages/qa/scenarios/src/skill-evals/summary.ts index f3ebd6e6fe5..40a661b260f 100644 --- a/packages/qa/scenarios/src/skill-evals/summary.ts +++ b/packages/qa/scenarios/src/skill-evals/summary.ts @@ -5,7 +5,10 @@ * rate of each arm, the with-skill failures, and the cases where the no-skill * arm did at least as well as the with-skill arm; per case, both arms' full * scores. `invalid` and `error` turns, and turns a stopped round never ran, - * are counted and named, and are never in a denominator. Pure over its inputs. + * are counted and named, and are never in a denominator. Trigger cases are + * tallied apart, beside the behaviour cases and never inside their rates: per + * bundle, how often the bundle was loaded when it should be and left alone + * when it should not. Pure over its inputs. */ import type { Arm } from './arms.js'; @@ -43,10 +46,43 @@ export interface BundleSummary { noSkillAtLeastWithSkill: string[]; } +/** One trigger case's with-skill turns: `pass` = loaded as `shouldTrigger` says. */ +export interface TriggerCaseScore { + key: string; + bundle: string; + shouldTrigger: boolean; + tally: ArmTally; + /** Judged turns that launched the bundle with the `Skill` tool. */ + loadedBySkillTool: number; + /** Judged turns that only read a file under it (no `Skill` launch). */ + loadedByReadOnly: number; +} + +export interface TriggerBundleSummary { + bundle: string; + cases: number; + /** The `should_trigger: true` cases' turns: `pass` = loaded. */ + shouldTrigger: ArmTally; + /** The `should_trigger: false` cases' turns: `pass` = left alone. */ + shouldNotTrigger: ArmTally; + /** Positive cases with at least one turn that did not load the bundle. */ + missedLoads: string[]; + /** Negative cases with at least one turn that loaded it. */ + falseLoads: string[]; +} + +export interface TriggerSummary { + bundles: TriggerBundleSummary[]; + cases: TriggerCaseScore[]; + totals: { shouldTrigger: ArmTally; shouldNotTrigger: ArmTally }; +} + export interface RoundSummary { + /** Behaviour cases only: trigger cases are in `triggers`. */ bundles: BundleSummary[]; cases: CaseScore[]; totals: { withSkill: ArmTally; noSkill: ArmTally }; + triggers: TriggerSummary; reportedCostUsd: number; } @@ -61,9 +97,22 @@ export function summariseRound( notRun: ReadonlyArray<{ case: SkillEvalCase; arm: Arm }>, ): RoundSummary { const byCase = new Map(); - for (const c of cases) byCase.set(c.key, { key: c.key, bundle: c.bundle, withSkill: empty(), noSkill: empty(), withSkillMissing: [], withSkillForbidden: [] }); + for (const c of cases) if (c.shouldTrigger === undefined) byCase.set(c.key, { key: c.key, bundle: c.bundle, withSkill: empty(), noSkill: empty(), withSkillMissing: [], withSkillForbidden: [] }); + const byTrigger = new Map(); + for (const c of cases) if (c.shouldTrigger !== undefined) byTrigger.set(c.key, { key: c.key, bundle: c.bundle, shouldTrigger: c.shouldTrigger, tally: empty(), loadedBySkillTool: 0, loadedByReadOnly: 0 }); let cost = 0; for (const r of records) { + const t = byTrigger.get(r.key); + if (t) { + if (r.reportedCostUsd !== undefined) cost += r.reportedCostUsd; + t.tally[r.verdict] += 1; + if (r.verdict === 'pass' || r.verdict === 'fail') { + const by = r.trigger?.loadedBy ?? []; + if (by.includes('skill-tool')) t.loadedBySkillTool += 1; + else if (by.includes('read')) t.loadedByReadOnly += 1; + } + continue; + } const s = byCase.get(r.key); if (!s) continue; s[armKey(r.arm)][r.verdict] += 1; @@ -76,6 +125,8 @@ export function summariseRound( for (const j of notRun) { const s = byCase.get(j.case.key); if (s) s[armKey(j.arm)].notRun += 1; + const t = byTrigger.get(j.case.key); + if (t) t.tally.notRun += 1; } const scores = [...byCase.values()].map((s) => ({ ...s, withSkill: withRate(s.withSkill), noSkill: withRate(s.noSkill) })); @@ -95,10 +146,33 @@ export function summariseRound( bundles, cases: scores, totals: { withSkill: bundles.reduce((t, b) => add(t, b.withSkill), empty()), noSkill: bundles.reduce((t, b) => add(t, b.noSkill), empty()) }, + triggers: summariseTriggers([...byTrigger.values()].map((t) => ({ ...t, tally: withRate(t.tally) }))), reportedCostUsd: Math.round(cost * 100) / 100, }; } +function summariseTriggers(scores: TriggerCaseScore[]): TriggerSummary { + const failed = (t: TriggerCaseScore) => t.tally.fail > 0; + const bundles = [...new Set(scores.map((s) => s.bundle))].sort().map((bundle): TriggerBundleSummary => { + const mine = scores.filter((s) => s.bundle === bundle); + const pos = mine.filter((s) => s.shouldTrigger); + const neg = mine.filter((s) => !s.shouldTrigger); + return { + bundle, + cases: mine.length, + shouldTrigger: pos.reduce((t, s) => add(t, s.tally), empty()), + shouldNotTrigger: neg.reduce((t, s) => add(t, s.tally), empty()), + missedLoads: pos.filter(failed).map((s) => s.key), + falseLoads: neg.filter(failed).map((s) => s.key), + }; + }); + return { + bundles, + cases: scores, + totals: { shouldTrigger: bundles.reduce((t, b) => add(t, b.shouldTrigger), empty()), shouldNotTrigger: bundles.reduce((t, b) => add(t, b.shouldNotTrigger), empty()) }, + }; +} + const pct = (t: ArmTally) => (t.rate === null ? 'not measured' : `${t.pass}/${t.pass + t.fail} (${Math.round(t.rate * 100)}%)`); const outOf = (t: ArmTally) => [t.invalid ? `${t.invalid} invalid` : '', t.error ? `${t.error} error` : '', t.notRun ? `${t.notRun} not run` : ''].filter(Boolean).join(', ') || '0'; /** @@ -131,5 +205,23 @@ export function renderSummaryMarkdown(s: RoundSummary, head: { title: string; li for (const c of s.cases) { out.push(`| ${c.key} | ${pct(c.withSkill)} | ${pct(c.noSkill)} | ${c.withSkillMissing.map(code).join(' ')} | ${c.withSkillForbidden.map(code).join(' ')} |`); } + const tr = s.triggers; + if (tr.cases.length) { + out.push( + '', + '## Trigger cases', + '', + 'With-skill arm only. A turn loaded the bundle when it launched it with the `Skill` tool or read a file under it; the case passes when that matches `should_trigger`.', + '', + '| bundle | cases | loaded when it should | left alone when it should not load | missed loads | false loads | out of the denominator |', + '|:--|--:|--:|--:|--:|--:|:--|', + ); + for (const b of tr.bundles) { + out.push(`| ${b.bundle} | ${b.cases} | ${pct(b.shouldTrigger)} | ${pct(b.shouldNotTrigger)} | ${b.missedLoads.length} | ${b.falseLoads.length} | ${outOf(add(b.shouldTrigger, b.shouldNotTrigger))} |`); + } + out.push(`| **all** | ${tr.cases.length} | ${pct(tr.totals.shouldTrigger)} | ${pct(tr.totals.shouldNotTrigger)} | ${tr.bundles.reduce((n, b) => n + b.missedLoads.length, 0)} | ${tr.bundles.reduce((n, b) => n + b.falseLoads.length, 0)} | ${outOf(add(tr.totals.shouldTrigger, tr.totals.shouldNotTrigger))} |`); + out.push('', '| trigger case | should load | as it should | loaded by Skill / by reading only |', '|:--|:--|--:|:--|'); + for (const t of tr.cases) out.push(`| ${t.key} | ${t.shouldTrigger ? 'yes' : 'no'} | ${pct(t.tally)} | ${t.loadedBySkillTool} / ${t.loadedByReadOnly} |`); + } return out.join('\n') + '\n'; } From 77049359dfcf06872b871fddd3a65c8f3dac8127 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 21:55:27 +0000 Subject: [PATCH 2/5] wip(skills): trigger cases for the six metadata skills; assertion and context review Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX --- .../evals/skills-tools-knowledge.json | 10 ++-- .../evals/endpoints-auth-routes.json | 6 +-- .../evals/flows-triggers-approvals.json | 4 +- .../evals/triggers.json | 47 +++++++++++++++++++ skills/objectstack-data/evals/README.md | 3 ++ .../hooks-security-seeds-datasources.json | 2 +- .../evals/objects-fields-relationships.json | 10 ++-- skills/objectstack-data/evals/triggers.json | 47 +++++++++++++++++++ .../objectstack-formula/evals/triggers.json | 47 +++++++++++++++++++ .../evals/bundles-locales-coverage.json | 6 +-- skills/objectstack-i18n/evals/triggers.json | 47 +++++++++++++++++++ .../evals/config-plugins-ops.json | 14 +++--- skills/objectstack-query/evals/triggers.json | 47 +++++++++++++++++++ skills/objectstack-ui/evals/README.md | 8 ++++ skills/objectstack-ui/evals/record-page.json | 2 +- skills/objectstack-ui/evals/triggers.json | 47 +++++++++++++++++++ .../evals/views-apps-actions-pages.json | 8 ++-- .../evals/protocol-major-upgrade.json | 10 ++-- skills/objectui/evals/data-integration.json | 2 +- skills/objectui/evals/page-builder.json | 6 +-- skills/objectui/evals/project-setup.json | 2 +- skills/objectui/evals/testing.json | 2 +- 22 files changed, 335 insertions(+), 42 deletions(-) create mode 100644 skills/objectstack-automation/evals/triggers.json create mode 100644 skills/objectstack-data/evals/triggers.json create mode 100644 skills/objectstack-formula/evals/triggers.json create mode 100644 skills/objectstack-i18n/evals/triggers.json create mode 100644 skills/objectstack-query/evals/triggers.json create mode 100644 skills/objectstack-ui/evals/triggers.json diff --git a/skills/objectstack-ai/evals/skills-tools-knowledge.json b/skills/objectstack-ai/evals/skills-tools-knowledge.json index 38c871b35f5..e317848290c 100644 --- a/skills/objectstack-ai/evals/skills-tools-knowledge.json +++ b/skills/objectstack-ai/evals/skills-tools-knowledge.json @@ -3,7 +3,7 @@ "evals": [ { "id": 1, - "prompt": "Add `src/skills/case-triage.skill.ts` for our support app: the assistant should be able to query and read support cases and run our existing `crm_escalate_case` Action on a case. Only activate it when the user is working on the `support_case` object.", + "prompt": "Add `src/skills/case-triage.skill.ts` for our support app: the assistant should be able to query and read support cases and run our existing `crm_escalate_case` Action on a case. Only activate it when the user is working on the `support_case` object. None of the project's files are in this directory: write the file in your answer.", "expected_output": "Emits a `defineSkill` with a snake_case `name`, `label`, `instructions`, and a `tools` list where every name resolves: platform tools `query_records` / `get_record` plus the action tool `action_crm_escalate_case` materialised from the stack's own Action. Routing is a `triggerConditions` entry `{ field: 'objectName', operator: 'eq', value: 'support_case' }` (a string value for `eq`). No `permissions` key on the skill (removed in 17) and no `*.agent.ts` file.", "files": [], "assertions": { @@ -33,7 +33,7 @@ }, { "id": 4, - "prompt": "Write a `*.tool.ts` so the assistant can call our `crm_close_case` action on a support case.", + "prompt": "Write a `*.tool.ts` so the assistant can call our `crm_close_case` action on a support case. None of the project's files are in this directory: write the file in your answer.", "expected_output": "Does not author a tool record: the default path is to opt the Action in with `ai: { exposed: true, description: '<40+ chars>' }` on the object's action, which materialises `action_crm_close_case`, and to name that tool in a skill's `tools`. `defineTool` is only for presentation refinement and cannot make anything executable (no `handler` / `implementation`; `ToolSchema` is strict).", "files": [], "assertions": { @@ -43,12 +43,12 @@ }, { "id": 5, - "prompt": "Create `src/ai/support-bot.agent.ts` with defineAgent({ name: 'crm_support_bot', tools: ['query_records', 'action_crm_close_case'], knowledge: ['support_kb'] }) and register it under agents.", + "prompt": "Create `src/ai/support-bot.agent.ts` with defineAgent({ name: 'crm_support_bot', tools: ['query_records', 'action_crm_close_case'], knowledge: ['support_kb'] }) and register it under agents. None of the project's files are in this directory: answer from what is stated here.", "expected_output": "Refuses the agent: the `agent` type is closed to third parties (a stack-authored agent is filtered out, refused by `loadAgent()` and 404s on chat), and `agent.tools` / `agent.knowledge` are protocol-17 tombstones. Re-declares the two tools in a `defineSkill` (registered under `skills`) with a `surface`, and restricts retrieval at the knowledge-source level (`aiExposed`, `where`) rather than on an agent. The runtime's `ask` / `build` agents pick the skill up by surface.", "files": [], "assertions": { "must_contain": ["defineSkill", "skills", "surface", "aiExposed"], - "must_not_contain": ["defineAgent(", "knowledge:"] + "must_not_contain": ["defineAgent({", "knowledge:"] } }, { @@ -57,7 +57,7 @@ "expected_output": "Does not decide on the token: the script may list the queue (`client.ai.pendingActions.list({ status: 'pending' })`), but approving or rejecting an item is the person's own act, done in the app on their signed-in session by the person the assistant call ran as. An API key or token is refused on the decide door, even the person's own, and so is an AI identity; another user's `ai:approve` does not decide the item, and the model's own confirmation does not count. The script reports or notifies the stale items instead; where a second person must approve the write, that is the approvals engine's `held` outcome.", "files": [], "assertions": { - "must_contain": ["pendingActions.list", "signed-in session", "refused"], + "must_contain": ["signed-in session", "refused"], "must_not_contain": ["pendingActions.approve("] } }, diff --git a/skills/objectstack-api/evals/endpoints-auth-routes.json b/skills/objectstack-api/evals/endpoints-auth-routes.json index 4e6fa573fb3..661126fc8be 100644 --- a/skills/objectstack-api/evals/endpoints-auth-routes.json +++ b/skills/objectstack-api/evals/endpoints-auth-routes.json @@ -3,7 +3,7 @@ "evals": [ { "id": 1, - "prompt": "Add `src/api/lead-feed.endpoint.ts`: a GET endpoint that returns our `acme_lead` records for a partner integration, cached for 30 seconds. The stack's manifest namespace is `acme`.", + "prompt": "Add `src/api/lead-feed.endpoint.ts`: a GET endpoint that returns our `acme_lead` records for a partner integration, cached for 30 seconds. The stack's manifest namespace is `acme`. None of the project's files are in this directory: write the file in your answer.", "expected_output": "Emits a declarative `ApiEndpoint` (registered under `defineStack({ apis })`): `path: '/api/v1/apps/acme/leads'` (the ADR-0121 carve-out — only the subpath is free), `method: 'GET'`, `type: 'object_operation'`, `objectParams: { object: 'acme_lead', operation: 'find' }`, `cacheTtlSeconds: 30`. `authRequired` is omitted (defaults to true). No handler code, no `transform` in a mapping, and `manifest.namespace` is declared explicitly.", "files": [], "assertions": { @@ -13,7 +13,7 @@ }, { "id": 2, - "prompt": "The partner can't send a session token — make the lead feed callable without login.", + "prompt": "Our `acme` stack ships a lead feed for a partner integration: a `GET` endpoint at `/api/v1/apps/acme/leads` of `type: 'object_operation'` over `acme_lead`, cached for 30 seconds. The partner can't send a session token — make the lead feed callable without login. None of the project's files are in this directory: write the change in your answer.", "expected_output": "Sets `authRequired: false` and, because ADR-0121 D6 pairs an anonymous entry point with an armed budget, adds `rateLimit: { enabled: true, windowMs: 60_000, maxRequests: 100 }`. Points out that the gate's predicate is `rateLimit.enabled === true`, so writing only `windowMs` / `maxRequests` declares a budget that meters nothing, and that the endpoint budget is independent of `server.security.rateLimit`.", "files": [], "assertions": { @@ -53,7 +53,7 @@ }, { "id": 6, - "prompt": "Our nightly CSV upsert of `supplier` rows by `tax_id` keeps resetting the `owner` column that sales reassigns by hand. Fix the import body.", + "prompt": "Our nightly CSV upsert of `supplier` rows by `tax_id` keeps resetting the `owner` column that sales reassigns by hand. Fix the import body. Today the job posts `{ format: 'csv', csv, mapping: { 'Tax ID': 'tax_id', Name: 'name', Owner: 'owner' }, writeMode: 'upsert', matchFields: ['tax_id'] }` to `POST /api/v1/data/supplier/import`. None of the project's files are in this directory: write the corrected body in your answer.", "expected_output": "Sends `mapping` as a `FieldMappingEntry[]` (the `{ Column: field }` shorthand cannot carry it) with `{ sourceField: 'Owner', targetField: 'owner', applyOn: 'create' }`: the column is written when the upsert creates the row and left out of the patch when it matches one; the other columns keep the default `applyOn: 'always'`. Keeps `writeMode: 'upsert'` and `matchFields: ['tax_id']`.", "files": [], "assertions": { diff --git a/skills/objectstack-automation/evals/flows-triggers-approvals.json b/skills/objectstack-automation/evals/flows-triggers-approvals.json index 71a8c84a220..d5ed631253b 100644 --- a/skills/objectstack-automation/evals/flows-triggers-approvals.json +++ b/skills/objectstack-automation/evals/flows-triggers-approvals.json @@ -80,7 +80,7 @@ }, { "id": 5, - "prompt": "Add a step calling our `pricing.recalc` function to compute the discount and save it on the quote, then post the quote to our tax service over HTTP; if the tax call fails, route to a handler node instead of failing the run.", + "prompt": "Add a step calling our `pricing.recalc` function to compute the discount and save it on the quote, then post the quote to our tax service over HTTP; if the tax call fails, route to a handler node instead of failing the run. None of the project's files are in this directory: write the flow nodes in your answer.", "expected_output": "A `script` node with `config.function: 'pricing.recalc'` (registered via `defineStack({ functions })`), `inputs` and `outputVariable: 'recalc'` — pure compute, so a following `update_record` persists `fields: { discount: { dialect: 'cel', source: 'recalc.discount' } }`. The `http` node sets `timeoutMs`. Failure routing is a `type: 'fault'` edge; a bare error label routes nothing.", "files": [], "assertions": { @@ -231,7 +231,7 @@ "files": [], "assertions": { "must_contain": [ - "hotcrm.custom", + ".custom", "overrides:", "basedOn", "/toggle" diff --git a/skills/objectstack-automation/evals/triggers.json b/skills/objectstack-automation/evals/triggers.json new file mode 100644 index 00000000000..0b6a9720100 --- /dev/null +++ b/skills/objectstack-automation/evals/triggers.json @@ -0,0 +1,47 @@ +{ + "skill_name": "objectstack-automation", + "evals": [ + { + "id": 1, + "prompt": "Through MCP on our ObjectStack environment: when an opportunity is closed won, notify its owner in their inbox.", + "should_trigger": true, + "files": [] + }, + { + "id": 2, + "prompt": "We build our ObjectStack app over MCP with no repository. Every night at 1:00, mark unpaid invoices whose due date has passed as `overdue`.", + "should_trigger": true, + "files": [] + }, + { + "id": 3, + "prompt": "Expense reports over 5,000 need their manager's approval in our ObjectStack app, and the submitter must never approve their own.", + "should_trigger": true, + "files": [] + }, + { + "id": 4, + "prompt": "Build a wizard in ObjectStack that walks a rep through onboarding a new client: company details, then an optional credit check, then it creates the account.", + "should_trigger": true, + "files": [] + }, + { + "id": 5, + "prompt": "在 ObjectStack 里,当工单的优先级变成「紧急」时,自动给负责人发一条站内通知。", + "should_trigger": true, + "files": [] + }, + { + "id": 6, + "prompt": "In our ObjectStack app, a `contract` must not save when its end date is before its start date.", + "should_trigger": false, + "files": [] + }, + { + "id": 7, + "prompt": "Write a GitHub Actions workflow that runs our test suite on every pull request and caches the pnpm store.", + "should_trigger": false, + "files": [] + } + ] +} diff --git a/skills/objectstack-data/evals/README.md b/skills/objectstack-data/evals/README.md index 061cbc218da..8859097f135 100644 --- a/skills/objectstack-data/evals/README.md +++ b/skills/objectstack-data/evals/README.md @@ -10,3 +10,6 @@ JSON fixtures in the objectui shape (`skill_name`, `evals[]`: `prompt`, - `hooks-security-seeds-datasources.json` — search mirrors via hooks, permission-set scopes, external datasources, seeds (`externalId`, CEL dynamic values). +- `triggers.json` — trigger cases (`should_trigger` in place of + `assertions`): requests that should load this skill and near misses that + should not, graded on whether the skill was loaded. diff --git a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json index 6bccdabab0c..4fae2982abd 100644 --- a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json +++ b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json @@ -158,7 +158,7 @@ "files": [], "assertions": { "must_contain": ["defineSeed", "+86 138", "@example.com"], - "must_not_contain": ["****", "'N/A'", "type: 'text', label: 'Phone'"] + "must_not_contain": ["'138****", "'N/A'", "type: 'text', label: 'Phone'"] } }, { diff --git a/skills/objectstack-data/evals/objects-fields-relationships.json b/skills/objectstack-data/evals/objects-fields-relationships.json index b70e73571cb..2be4cd6fd8c 100644 --- a/skills/objectstack-data/evals/objects-fields-relationships.json +++ b/skills/objectstack-data/evals/objects-fields-relationships.json @@ -3,7 +3,7 @@ "evals": [ { "id": 1, - "prompt": "Create `src/objects/vendor.object.ts` for our vendors: company name, contact email, a status (Active / Inactive), the API key we use to call their system, and the password for their supplier portal.", + "prompt": "Create `src/objects/vendor.object.ts` for our vendors: company name, contact email, a status (Active / Inactive), the API key we use to call their system, and the password for their supplier portal. None of the project's files are in this directory: write the file in your answer.", "expected_output": "Emits `ObjectSchema.create({...})` with a snake_case `name`, an authored `sharingModel` (a publish with none is refused), `label` / `pluralLabel` / `icon`, `nameField`, and fields with snake_case keys and camelCase config properties: `text` (required), `email`, a `select` whose `options` carry lowercase `value`s (`active`, `inactive`), and BOTH credentials as `type: 'secret'` (encrypted at rest) — never `type: 'password'`, which is plaintext at rest on a generic object. No `namespace` or `tableName` key.", "files": [], "assertions": { @@ -158,7 +158,7 @@ }, { "id": 9, - "prompt": "Our app runs multi-tenant. Add an index on `ticket` for the list every agent opens: their organization's open tickets, newest first.", + "prompt": "Our app runs multi-tenant. Add an index on `ticket` for the list every agent opens: their organization's open tickets, newest first. None of the project's files are in this directory: write the change in your answer.", "expected_output": "`indexes: [{ fields: ['organization_id', 'status', 'created_at'] }]` — the tenant column is `organization_id`, injected by `systemFields.tenant`, so it is indexed but not declared as a field; an index naming an undeclared `tenant_id` is refused. The platform already adds the single-column `organization_id` index on a multi-tenant host.", "files": [], "assertions": { @@ -181,7 +181,7 @@ "label: '是否完成'" ], "must_not_contain": [ - "required: true", + "required: true,", "required: true }", "label: 'Is Done'" ] } @@ -214,7 +214,7 @@ "must_contain": [ "type: 'summary'", "function: 'count'", - "filter: { status: 'completed' }", + "filter:", "type: 'formula'" ], "must_not_contain": [ @@ -249,7 +249,7 @@ "must_contain": [ "label: '供应商'", "label: '公司名称'", - "value: 'active'", + "value: '", "sharingModel" ], "must_not_contain": [ diff --git a/skills/objectstack-data/evals/triggers.json b/skills/objectstack-data/evals/triggers.json new file mode 100644 index 00000000000..865c40d9ef7 --- /dev/null +++ b/skills/objectstack-data/evals/triggers.json @@ -0,0 +1,47 @@ +{ + "skill_name": "objectstack-data", + "evals": [ + { + "id": 1, + "prompt": "I'm building an ObjectStack app through its MCP server, with no project files. Create a `vendor` object with a company name, a contact email, and an Active / Inactive status.", + "should_trigger": true, + "files": [] + }, + { + "id": 2, + "prompt": "Through MCP on our ObjectStack environment, add a lookup from `invoice` to `account`, and block deleting an account while it still has invoices.", + "should_trigger": true, + "files": [] + }, + { + "id": 3, + "prompt": "Model invoices and their line items in ObjectStack: deleting an invoice deletes its lines, and the invoice shows the total of its lines.", + "should_trigger": true, + "files": [] + }, + { + "id": 4, + "prompt": "Our ObjectStack app needs demo data: twenty sample `opportunity` rows for dev and test only, closing 30 days after install.", + "should_trigger": true, + "files": [] + }, + { + "id": 5, + "prompt": "在 ObjectStack 里给 `contract` 对象加一个「签署日期」字段:只有状态是已签署时才显示,并且那时必须填写。", + "should_trigger": true, + "files": [] + }, + { + "id": 6, + "prompt": "Write an ObjectQL query on `ticket` that returns the ten newest open tickets assigned to me, with each ticket's account name.", + "should_trigger": false, + "files": [] + }, + { + "id": 7, + "prompt": "In plain PostgreSQL, with no ObjectStack involved, write a migration that adds a NOT NULL `region` column with a default to a 50-million-row table without holding a long lock.", + "should_trigger": false, + "files": [] + } + ] +} diff --git a/skills/objectstack-formula/evals/triggers.json b/skills/objectstack-formula/evals/triggers.json new file mode 100644 index 00000000000..65653569acb --- /dev/null +++ b/skills/objectstack-formula/evals/triggers.json @@ -0,0 +1,47 @@ +{ + "skill_name": "objectstack-formula", + "evals": [ + { + "id": 1, + "prompt": "In ObjectStack, write the CEL expression for a formula field that shows the days remaining until `close_date`.", + "should_trigger": true, + "files": [] + }, + { + "id": 2, + "prompt": "Translate this Salesforce validation formula to ObjectStack: AND(ISPICKVAL(Stage, 'Closed Won'), ISBLANK(Contract_Signed_Date__c)).", + "should_trigger": true, + "files": [] + }, + { + "id": 3, + "prompt": "How do I express \"the status has just changed to escalated\" as a condition in ObjectStack, so it holds once per change, on single and bulk updates alike?", + "should_trigger": true, + "files": [] + }, + { + "id": 4, + "prompt": "An ObjectStack seed should set `due_date` to 14 days after the package is installed. What value do I write for it?", + "should_trigger": true, + "files": [] + }, + { + "id": 5, + "prompt": "ObjectStack 里,`discount_reason` 字段只有在填了折扣金额时才显示,这个条件表达式怎么写?", + "should_trigger": true, + "files": [] + }, + { + "id": 6, + "prompt": "Write an ObjectQL filter for tasks whose `due_at` is before now and whose status is not done, newest first.", + "should_trigger": false, + "files": [] + }, + { + "id": 7, + "prompt": "In Excel, write a formula that returns the number of working days between the dates in A2 and B2, skipping the holidays listed in H2:H20.", + "should_trigger": false, + "files": [] + } + ] +} diff --git a/skills/objectstack-i18n/evals/bundles-locales-coverage.json b/skills/objectstack-i18n/evals/bundles-locales-coverage.json index 791598e882e..5df5308698a 100644 --- a/skills/objectstack-i18n/evals/bundles-locales-coverage.json +++ b/skills/objectstack-i18n/evals/bundles-locales-coverage.json @@ -13,7 +13,7 @@ }, { "id": 2, - "prompt": "We are adding Japanese to the app.", + "prompt": "We are adding Japanese to the app. None of the project's files are in this directory: answer with the configuration change and the commands to run.", "expected_output": "Adds `'ja-JP'` (BCP-47) to `i18n.supportedLocales`, keeps `defaultLocale` / `fallbackLocale`, scaffolds the skeleton with `os i18n extract --locales=ja-JP --out=./src/translations`, adds the `'ja-JP'` key to the bundle, and verifies with `os i18n check --locales=ja-JP`.", "files": [], "assertions": { @@ -33,7 +33,7 @@ }, { "id": 4, - "prompt": "Our storage plugin ships its own generated `objects` translations for `en` and `zh-CN`. Wire them in.", + "prompt": "Our storage plugin ships its own generated `objects` translations for `en` and `zh-CN`. Wire them in. The plugin's source is not in this directory: write the code in your answer.", "expected_output": "Wraps the generated subtree into a `TranslationData` (`{ objects: enObjects }`), builds the bundle with `defineTranslationBundle`, and wraps the translated locale with `withSourceFallback(..., enSource, undefined, zhCNGeneratedSourceHashes)` so a leaf whose source moved is not served forever under a green check. A plugin that owns its objects loads it from its own `kernel:ready` hook via `i18n.loadTranslations(locale, data)` (deep-merge) rather than the stack.", "files": [], "assertions": { @@ -98,7 +98,7 @@ "files": [], "assertions": { "must_contain": ["_actions", "crm_renew", "preflight", "fields", "verdict.summary"], - "must_not_contain": ["title:", "verdict: {"] + "must_not_contain": ["title:", "verdict: { summary: '"] } }, { diff --git a/skills/objectstack-i18n/evals/triggers.json b/skills/objectstack-i18n/evals/triggers.json new file mode 100644 index 00000000000..3176a35e3b4 --- /dev/null +++ b/skills/objectstack-i18n/evals/triggers.json @@ -0,0 +1,47 @@ +{ + "skill_name": "objectstack-i18n", + "evals": [ + { + "id": 1, + "prompt": "Our ObjectStack app needs Simplified Chinese: translate the `account` object's label and its `industry` field's options.", + "should_trigger": true, + "files": [] + }, + { + "id": 2, + "prompt": "Through the ObjectStack metadata API over MCP, with no project files, relabel `opportunity` as 商机 for our Chinese users.", + "should_trigger": true, + "files": [] + }, + { + "id": 3, + "prompt": "We are adding Japanese to our ObjectStack app. What configuration and tooling does that take?", + "should_trigger": true, + "files": [] + }, + { + "id": 4, + "prompt": "`os i18n check` says zh-CN is missing navigation keys. How do we find and fill them?", + "should_trigger": true, + "files": [] + }, + { + "id": 5, + "prompt": "我们的 ObjectStack 应用要支持繁体中文,导航菜单和仪表盘标题也要翻译。", + "should_trigger": true, + "files": [] + }, + { + "id": 6, + "prompt": "In a plain React app without ObjectStack, set up react-i18next with lazy-loaded language files and a language switcher.", + "should_trigger": false, + "files": [] + }, + { + "id": 7, + "prompt": "Format a currency amount for German users in a Node.js script with Intl.NumberFormat.", + "should_trigger": false, + "files": [] + } + ] +} diff --git a/skills/objectstack-platform/evals/config-plugins-ops.json b/skills/objectstack-platform/evals/config-plugins-ops.json index 637e92fe0d8..e06f6a9605c 100644 --- a/skills/objectstack-platform/evals/config-plugins-ops.json +++ b/skills/objectstack-platform/evals/config-plugins-ops.json @@ -3,7 +3,7 @@ "evals": [ { "id": 1, - "prompt": "Write `objectstack.config.ts` for our CRM app: objects, views and flows under src/, namespace `crm`, protocol 18.", + "prompt": "Write `objectstack.config.ts` for our CRM app: objects, views and flows under src/, namespace `crm`, protocol 18. None of the project's files are in this directory: write the file in your answer.", "expected_output": "`defineStack` with a `manifest` of `id`, `version`, `type: 'app'`, `name`, `namespace: 'crm'`, `engines: { protocol: '^18' }`; barrel imports, `objects: Object.values(objects)` (likewise `views` / `flows`); prefixed object names (`crm_account`), no object-level `namespace`, no `tableName`; no driver in `plugins:` (the CLI resolves it); no `workflows` / `approvals` keys (refused).", "files": [], "assertions": { @@ -41,7 +41,7 @@ }, { "id": 3, - "prompt": "Our scheduled flows never launch, and `notify` reports success but nobody receives anything.", + "prompt": "Our scheduled flows never launch, and `notify` reports success but nobody receives anything. The project's `objectstack.config.ts` is not in this directory: answer with what to check and change in it.", "expected_output": "`requires: ['automation', 'triggers']` on the stack root: `triggers` arms the start bindings, and schedule and time-relative ones run on the `job` service. `job` and `messaging` are always-on: a default boot mounts both, listed or not. Only a `--preset minimal` boot drops them; there, list `job` too (else scheduled flows stay silent) and `messaging` (else notify returns success with `skipped: true`). Declaring is a demand (missing provider = hard boot error); `defineStack` rejects an unknown token at authoring time.", "files": [], "assertions": { @@ -75,7 +75,7 @@ }, { "id": 5, - "prompt": "I changed field types on an object with production data. Show me what the database needs, verify the metadata and give me a quality score.", + "prompt": "I changed field types on an object with production data. Show me what the database needs, verify the metadata and give me a quality score. None of the project's files are in this directory: answer with the commands to run.", "expected_output": "`os migrate plan` previews the drift, `os migrate apply` (`--allow-destructive` for type changes / drops) reconciles, then `os validate` and `os lint --score`; not done until `os validate` passes, which `os lint` does not replace.", "files": [], "assertions": { @@ -111,7 +111,7 @@ }, { "id": 7, - "prompt": "Prepare a demo of our contracts app: the seed assigns matters to 'Legal Counsel 1' and 'Paralegal 1', and the demo opens signed in as Legal Counsel 1.", + "prompt": "Prepare a demo of our contracts app: the seed assigns matters to 'Legal Counsel 1' and 'Paralegal 1', and the demo opens signed in as Legal Counsel 1. None of the project's files are in this directory: write the configuration in your answer.", "expected_output": "Both go in `demoStaff` — `name` as the seed references them, `email`, a `position` / `permissionSets` the stack declares — and `os dev` creates the accounts with the seed password: no `password` key, no `role` alias, no platform set, no hand-written `sys_user` seed row. `devLogins` creates nothing (at most a banner entry); `os build` drops `demoStaff`; production creates no demo account.", "files": [], "assertions": { @@ -129,7 +129,7 @@ }, { "id": 8, - "prompt": "In the contracts demo Paralegal 1 reports to Legal Counsel 1; the approval flow's manager step must reach the right person on a fresh `os dev`.", + "prompt": "In the contracts demo Paralegal 1 reports to Legal Counsel 1; the approval flow's manager step must reach the right person on a fresh `os dev`. None of the project's files are in this directory: write the configuration in your answer.", "expected_output": "On Paralegal 1's `demoStaff` entry, `manager: 'counsel1@example.com'` — Legal Counsel 1's entry `email`, never the display name — and nothing else: `os dev` writes `sys_user.manager_id` once every demo account exists. No seed row or hook writing `manager_id`, no `reportsTo` / `managerEmail` alias (refused); a manager naming no entry, itself or a loop is refused at load.", "files": [], "assertions": { @@ -290,7 +290,7 @@ }, { "id": 17, - "prompt": "I edited an object in my app locally. How do I see my change on my ObjectOS Cloud environment?", + "prompt": "I edited an object in my app locally. How do I see my change on my ObjectOS Cloud environment? None of the project's files are in this directory: answer with the commands to run.", "expected_output": "Run `os deploy` from the project (`npm run deploy` in a scaffolded project, or press `d` in `os dev`). It builds, publishes `-dev.`, installs it into your organization's only environment (or `--env `, or the one `os environments switch` recorded) and waits until the environment serves it; `--no-wait` returns once the install is recorded. `os package publish` is for publishing a release version, not for this loop. On exit 1, a refusal before any write published nothing (log in with `os cloud login`, or pass `--env`); `could not build` is the environment's build failing while it keeps serving the previous build; a timeout means the install is recorded, so deploy again with a longer `--wait-timeout` or check the build in the ObjectOS Cloud console.", "files": [], "assertions": { @@ -350,7 +350,7 @@ }, { "id": 21, - "prompt": "We run ObjectStack's Docker image on our own server at https://objectos.example.com. How do I deploy my app there from the project without typing its URL and key every time?", + "prompt": "We run ObjectStack's Docker image on our own server at https://objectos.example.com. How do I deploy my app there from the project without typing its URL and key every time? None of the project's files are in this directory: answer with the commands to run.", "expected_output": "Remember the runtime once: `os environments use-runtime https://objectos.example.com --token `, with an API key that runtime issued. The key is tried on the runtime before anything is recorded (`--no-verify` skips that), then kept in `~/.objectstack/cloud.json` (0600), across cloud login and logout. From then on `os deploy` (or `d` in `os dev`) deploys there: it builds, prints the runtime's dry-run upgrade plan, installs the build inline, and reports it live when the runtime answers `hotLoaded`; `--confirm-access-upgrade ` confirms the access findings a refusal printed. `os package install` falls back to that runtime when `-u` is not given. `os environments use-runtime --forget` or `os environments switch ` makes ObjectOS Cloud the target again.", "files": [], "assertions": { diff --git a/skills/objectstack-query/evals/triggers.json b/skills/objectstack-query/evals/triggers.json new file mode 100644 index 00000000000..05c4959ea13 --- /dev/null +++ b/skills/objectstack-query/evals/triggers.json @@ -0,0 +1,47 @@ +{ + "skill_name": "objectstack-query", + "evals": [ + { + "id": 1, + "prompt": "Using ObjectQL, find accounts in the US or Canada whose name contains 'tech', case-insensitively, highest annual revenue first.", + "should_trigger": true, + "files": [] + }, + { + "id": 2, + "prompt": "Our ObjectStack app has millions of `audit_event` rows. Which pagination should the activity feed use to scroll back through them newest first, and how is the query written?", + "should_trigger": true, + "files": [] + }, + { + "id": 3, + "prompt": "I'm connected to an ObjectStack environment over MCP. In one call, how many deals were won per sales region this quarter, and what is the average amount per region?", + "should_trigger": true, + "files": [] + }, + { + "id": 4, + "prompt": "Search ObjectStack `knowledge_article` records by keyword across the title and the body, and return each article's author name with it.", + "should_trigger": true, + "files": [] + }, + { + "id": 5, + "prompt": "用 ObjectQL 查出本月到期、还没付款的发票,按到期日升序,每页 50 条。", + "should_trigger": true, + "files": [] + }, + { + "id": 6, + "prompt": "Add a `priority` select field (Low / Medium / High) to the `ticket` object in our ObjectStack app, defaulting to Medium.", + "should_trigger": false, + "files": [] + }, + { + "id": 7, + "prompt": "In our ObjectStack app, add a list view on `ticket` that shows only the signed-in user's open tickets.", + "should_trigger": false, + "files": [] + } + ] +} diff --git a/skills/objectstack-ui/evals/README.md b/skills/objectstack-ui/evals/README.md index 304c2d54306..2bc42952c4a 100644 --- a/skills/objectstack-ui/evals/README.md +++ b/skills/objectstack-ui/evals/README.md @@ -24,6 +24,9 @@ view / page / dashboard / report metadata. docs, wizard forms, a view added beside the list (and the empty board over a field added with it), a write button whose body writes, the view kind the request names. +- `triggers.json` — trigger cases: requests that should load this skill + (`should_trigger: true`) and near misses that should not (`false`), graded + on whether the skill was loaded, never on the answer. ## Format @@ -33,6 +36,11 @@ Each eval file is a JSON fixture with a list of evals, each carrying: 2. **expected_output** — what a correct answer does (and avoids) 3. **assertions** — `must_contain` / `must_not_contain` string checks used to score the output +4. **files** — paths under `evals/files/` a case needs on disk (empty when + the prompt states its context) + +A trigger case carries `should_trigger` in place of `expected_output` and +`assertions`. ## Contributing diff --git a/skills/objectstack-ui/evals/record-page.json b/skills/objectstack-ui/evals/record-page.json index dea52485dff..f9de9323a6e 100644 --- a/skills/objectstack-ui/evals/record-page.json +++ b/skills/objectstack-ui/evals/record-page.json @@ -38,7 +38,7 @@ }, { "id": 3, - "prompt": "Our account record page is a custom `kind: 'full'` page with its own tab strip. Installed packages keep adding header actions to `account` (an 'Open in billing' link, for one), and none of them ever shows in the page header. Make the header show every action placed on the account's header, including ones a package adds later, without us listing ids.", + "prompt": "Our account record page is a custom `kind: 'full'` page with its own tab strip. Installed packages keep adding header actions to `account` (an 'Open in billing' link, for one), and none of them ever shows in the page header. Make the header show every action placed on the account's header, including ones a package adds later, without us listing ids. None of the project's files are in this directory: write the change in your answer.", "expected_output": "Keep the `kind: 'full'` page and its tab strip, and set `placedActions: true` on its `page:header` node: `{ type: 'page:header', properties: { placedActions: true } }`. The header then draws every action of `account` whose `locations` include `record_header` or `record_more`, read live, so a package's action appears without a page edit. No `actions` id list beside it: an authored list is the whole set, and `placedActions: true` beside one is refused. Not a return to a `slotted` page and never a `slots.tabs`.", "files": [], "assertions": { diff --git a/skills/objectstack-ui/evals/triggers.json b/skills/objectstack-ui/evals/triggers.json new file mode 100644 index 00000000000..736f2b793a9 --- /dev/null +++ b/skills/objectstack-ui/evals/triggers.json @@ -0,0 +1,47 @@ +{ + "skill_name": "objectstack-ui", + "evals": [ + { + "id": 1, + "prompt": "Through the ObjectStack MCP server, give the `deal` object a kanban board grouped by stage.", + "should_trigger": true, + "files": [] + }, + { + "id": 2, + "prompt": "I have no project files, only an ObjectStack environment I reach over MCP. Build a sales dashboard with a revenue-by-month chart and a KPI for the open pipeline.", + "should_trigger": true, + "files": [] + }, + { + "id": 3, + "prompt": "Add a 'Mark as won' button on the opportunity record page of our ObjectStack app that sets the stage to won.", + "should_trigger": true, + "files": [] + }, + { + "id": 4, + "prompt": "Design the app navigation for our ObjectStack support app: a Tickets menu, a 'My open tickets' entry, and the support dashboard.", + "should_trigger": true, + "files": [] + }, + { + "id": 5, + "prompt": "在 ObjectStack 里做一个客户列表视图:只显示活跃客户,按创建时间倒序,并且能切换成看板。", + "should_trigger": true, + "files": [] + }, + { + "id": 6, + "prompt": "Build a guided ObjectStack screen flow that asks whether a credit check is needed and branches to a credit-check step only when it is.", + "should_trigger": false, + "files": [] + }, + { + "id": 7, + "prompt": "In a plain React app with no ObjectStack, write a responsive card grid component with Tailwind that collapses to one column on phones.", + "should_trigger": false, + "files": [] + } + ] +} diff --git a/skills/objectstack-ui/evals/views-apps-actions-pages.json b/skills/objectstack-ui/evals/views-apps-actions-pages.json index f287b10c568..e03630631ee 100644 --- a/skills/objectstack-ui/evals/views-apps-actions-pages.json +++ b/skills/objectstack-ui/evals/views-apps-actions-pages.json @@ -3,7 +3,7 @@ "evals": [ { "id": 1, - "prompt": "Create `src/views/support-case.view.ts`: a default grid (subject linking to the record, status, priority, owner, due date), a 'My Open Cases' list, a kanban by status, and a simple edit form.", + "prompt": "Create `src/views/support-case.view.ts`: a default grid (subject linking to the record, status, priority, owner, due date), a 'My Open Cases' list, a kanban by status, and a simple edit form. None of the project's files are in this directory: write the file in your answer.", "expected_output": "One `defineView({ list, form, listViews })` container — never a bare flat view object. `data: { provider: 'object', object: 'support_case' }`, `columns` with `link: true` on `subject`, the owner column is the injected `owner_id` (never an `assigned_to` field), a `listViews.my_open` entry with `filter` triples (`{ field: 'owner_id', operator: 'equals', value: '{current_user_id}' }`), a kanban entry with the required top-level `columns` plus `kanban: { groupByField: 'status' }` (no top-level `groupBy`), and `form` with `type: 'simple'` and `sections` referencing a declared field group.", "files": [], "assertions": { @@ -13,7 +13,7 @@ }, { "id": 2, - "prompt": "Build `src/apps/crm.app.ts`: a Sales group with Leads, Opportunities, the pipeline kanban, a 'My open deals' entry and the sales dashboard; an Approvals group that only shows when approvals are installed; and a second app for the support team, who work the same objects.", + "prompt": "Build `src/apps/crm.app.ts`: a Sales group with Leads, Opportunities, the pipeline kanban, a 'My open deals' entry and the sales dashboard; an Approvals group that only shows when approvals are installed; and a second app for the support team, who work the same objects. None of the project's files are in this directory: write the file in your answer.", "expected_output": "`App.create({...})` with a `navigation` tree of `group` items: `type: 'object'` entries with `objectName`, a `viewName: 'pipeline_kanban'` shortcut, a bare `filters: { owner_id: '{current_user_id}', status: 'open' }` slice for 'My open deals' (no view authored for a one-off), `type: 'dashboard'` with `dashboardName`, and the approvals inbox as `type: 'component', componentRef: 'approvals:inbox'` gated by `requiresService: 'approvals'` (never a `requiresObject` gate on `sys_approval_request`: that object read answers 404 to an approver until a request involves them). At most one app per package, so not a second `App.create` here: the support team shares this product and its objects, so it is a `requiredPermissions`-gated group inside the app. (A support product with objects of its own would carry its app in its own `type: 'module'` package of the suite.) Registered under `defineStack({ apps })`.", "files": [], "assertions": { @@ -33,7 +33,7 @@ }, { "id": 4, - "prompt": "Design a custom lead record page: the Convert action inline in the header, a highlights strip, a stage path over `status`, and the related contacts. Also write a user guide for the `crm` package under src/docs and link it from the nav.", + "prompt": "Design a custom lead record page: the Convert action inline in the header, a highlights strip, a stage path over `status`, and the related contacts. Also write a user guide for the `crm` package under src/docs and link it from the nav. None of the project's files are in this directory: write the files in your answer.", "expected_output": "`definePage({ name, label, type: 'record', object: 'lead', template: 'three-column', regions: [...] })` with `page:header` (the declared action's id in `properties.actions`, no sibling action node), `record:highlights`, `record:path` (`statusField`, `stages`), `record:related_list`. The guide is a flat, namespace-prefixed `src/docs/crm_user_guide.md` in pure Markdown (MDX and image references are rejected at build), surfaced by a `type: 'doc'` nav item (`doc: 'crm_user_guide'`).", "files": [], "assertions": { @@ -157,7 +157,7 @@ "expected_output": "One `defineAction` (`type: 'api'`, that `target` with `${ctx.recordId}`) whose `params` are `version` and `plan_token` (both `required`; `plan_token` declares no default or carry-over), beside `preflight: { read: { url: '/api/v1/packages/${ctx.recordId}/upgrade-plan?version=${param.version}' }, path: 'data', fields: [{ path: 'changes', label: 'Changes', format: 'json' }], seed: [{ param: 'plan_token', path: 'token' }] }`. The dialog sends that one same-origin GET once `version` has a value, shows `changes` above the params, and fills `plan_token` read-only, so Confirm waits for the answer. Not a script or companion action that fetches the plan by hand, not an absolute URL, credential headers or a non-GET read, and no `result` hole (there is no answer before the read); the endpoint still checks the token.", "files": [], "assertions": { - "must_contain": ["preflight", "read: { url: '/api/v1/packages/${ctx.recordId}/upgrade-plan?version=${param.version}' }", "seed: [{ param: 'plan_token', path: 'token' }]"], + "must_contain": ["preflight", "/api/v1/packages/${ctx.recordId}/upgrade-plan?version=${param.version}", "seed:", "path: 'token'"], "must_not_contain": ["headers:", "${result."] } }, diff --git a/skills/objectstack-upgrade/evals/protocol-major-upgrade.json b/skills/objectstack-upgrade/evals/protocol-major-upgrade.json index c8edddc9624..53a7d4469f4 100644 --- a/skills/objectstack-upgrade/evals/protocol-major-upgrade.json +++ b/skills/objectstack-upgrade/evals/protocol-major-upgrade.json @@ -3,7 +3,7 @@ "evals": [ { "id": 1, - "prompt": "把这个项目升级到 v17。objectstack.config.ts 的 manifest 里写着 engines: { protocol: '^16' }。", + "prompt": "把这个项目升级到 v17。objectstack.config.ts 的 manifest 里写着 engines: { protocol: '^16' }。当前目录里没有这个项目的文件:请直接给出你要运行的命令、每一步要检查什么,以及最后交付什么。", "expected_output": "Preflight: `--from 16` read off `manifest.engines.protocol` (the floor of the range, never guessed from the installed spec); keep `os validate > .upgrade/validate-before.txt` as the control. Mechanical: `os migrate meta --from 16 --step`, `--json`, and `--out .upgrade/migrated.stack.json` — the command rewrites nothing on disk, so port the printed `path: from → to (conversionId)` edits into the sources, one `conversionId` per commit, then replay the ported hop, `os migrate meta --from 16 --to 17 --json`, until `applied` is `[]` with no `replayedNothing` (`--from 17` names an empty range and checks nothing). Acceptance: `os validate` green, `tsc --noEmit` green, and `.upgrade/REPORT.md` with the mechanical table, decided residue, open decisions and pending per-deployment gates.", "files": [], "assertions": { @@ -13,7 +13,7 @@ }, { "id": 2, - "prompt": "After bumping @objectstack/spec, tsc fails: `conditionalRequired` does not exist ... [REMOVED] use `requiredWhen`. Just fix it for me.", + "prompt": "After bumping @objectstack/spec, tsc fails: `conditionalRequired` does not exist ... [REMOVED] use `requiredWhen`. Just fix it for me. None of the project's files are in this directory: answer with the commands you run and the change itself.", "expected_output": "Does not hand-write the rewrite: the chain already knows the rename, so it runs `os migrate meta --from ` to attribute the site to its `conversionId`, ports `requiredWhen` with the value unchanged, and confirms with `tsc --noEmit` (tombstones type the retired key as `never`). It is a decide-alone item (one target, evidence in the repo, being wrong fails a gate). Never adds a tolerant read or `??` alias so the old key keeps loading; finishes with the prose sweep for `conditionalRequired` in READMEs, comments and the project's AI conventions file.", "files": [], "assertions": { @@ -23,12 +23,12 @@ }, { "id": 3, - "prompt": "The chain dropped `connectors[sap_erp].fieldMappings[].transform` = { type: 'javascript', expression: 'value / 100' }. Decide what to do with it.", + "prompt": "The chain dropped `connectors[sap_erp].fieldMappings[].transform` = { type: 'javascript', expression: 'value / 100' }. Decide what to do with it. None of the project's files are in this directory: answer from what is stated here.", "expected_output": "Classifies it as R1 (intent choice): the tombstone names one live target (import-mapping `transform`, a string enum with no `javascript` member) while the real options are import mapping, an ETL step where it actually runs, or delete because the member never executed — so the choice is a business statement and the owner decides. Asks with one message carrying the site, the prescription verbatim, the options and their costs, a recommendation and what will be verified; parks the item in the report as `AWAITING DECISION` and keeps the mechanical layer moving.", "files": [], "assertions": { - "must_contain": ["AWAITING DECISION", "owner", "never executed", "transform"], - "must_not_contain": ["type: 'javascript'"] + "must_contain": ["AWAITING DECISION", "owner", "transform"], + "must_not_contain": ["transform: { type: 'javascript'"] } }, { diff --git a/skills/objectui/evals/data-integration.json b/skills/objectui/evals/data-integration.json index d5264b52c01..facd2214730 100644 --- a/skills/objectui/evals/data-integration.json +++ b/skills/objectui/evals/data-integration.json @@ -39,7 +39,7 @@ }, { "id": 3, - "prompt": "My ObjectUI table shows 'undefined' for all rows. The dataSource.find() call returns data correctly in the console. What's wrong?", + "prompt": "My ObjectUI table shows 'undefined' for all rows. The dataSource.find() call returns data correctly in the console. What's wrong? The app's source is not in this directory: answer from what is stated here.", "expected_output": "Diagnoses likely bind path mismatch or missing SchemaRendererProvider. Shows correct data flow: provider → bind → useDataScope resolution.", "files": [], "assertions": { diff --git a/skills/objectui/evals/page-builder.json b/skills/objectui/evals/page-builder.json index 5336ed29477..919b8264d6e 100644 --- a/skills/objectui/evals/page-builder.json +++ b/skills/objectui/evals/page-builder.json @@ -22,7 +22,7 @@ }, { "id": 2, - "prompt": "Convert our customer detail page (React + TypeScript) to schema-driven UI: sections Basic Info, Contacts and Recent Orders, and an 'Edit Customer' button visible only to admins.", + "prompt": "Convert our customer detail page (React + TypeScript) to schema-driven UI: sections Basic Info, Contacts and Recent Orders, and an 'Edit Customer' button visible only to admins. The page's source is not in this directory: write the schema in your answer.", "expected_output": "A detail-page schema with modular sections, expression-based visibility on the admin-only action, and app integration steps.", "files": [], "assertions": { @@ -39,7 +39,7 @@ }, { "id": 3, - "prompt": "Build an analytics dashboard page in an existing ObjectUI project: KPI cards on top, a trend chart, a recent-activity list at the bottom, plus refresh and navigate-to-report actions.", + "prompt": "Build an analytics dashboard page in an existing ObjectUI project: KPI cards on top, a trend chart, a recent-activity list at the bottom, plus refresh and navigate-to-report actions. None of the project's files are in this directory: write the schema in your answer.", "expected_output": "A dashboard schema with layout composition, a plugin chart, actions as data, and responsiveness and interaction testing guidance.", "files": [], "assertions": { @@ -54,7 +54,7 @@ }, { "id": 4, - "prompt": "Add a 'Delete product' button to the product detail page. It must read as destructive and ask the user to confirm before the record is removed.", + "prompt": "Add a 'Delete product' button to the product detail page. It must read as destructive and ask the user to confirm before the record is removed. None of the project's files are in this directory: write the schema in your answer.", "expected_output": "An action:button whose properties carry label, actionType, target, a confirmText question and variant 'danger': the button draws red and asks that question through the destructive confirm button. On an action block the Button primitive's spelling of that arm is refused at save; danger is the action runner's word.", "files": [], "assertions": { diff --git a/skills/objectui/evals/project-setup.json b/skills/objectui/evals/project-setup.json index 0ddd831a982..cd5721edd2c 100644 --- a/skills/objectui/evals/project-setup.json +++ b/skills/objectui/evals/project-setup.json @@ -40,7 +40,7 @@ }, { "id": 3, - "prompt": "How do I add the grid and kanban plugins to my existing ObjectUI project and make sure they're available in my schemas?", + "prompt": "How do I add the grid and kanban plugins to my existing ObjectUI project and make sure they're available in my schemas? None of the project's files are in this directory: answer with the commands and the code.", "expected_output": "Shows installing @object-ui/plugin-grid and @object-ui/plugin-kanban, the side-effect import at the app entry that registers each plugin's renderers in ComponentRegistry (without it SchemaRenderer resolves the node to 'Unknown component type'), and the schema type to use afterwards. On styling: the plugin packages publish no stylesheet of their own — only @object-ui/components and @object-ui/fields export a ./style.css — so there is no third sheet to import and nothing to point Tailwind at inside node_modules. Inside the ObjectUI workspace the app owns the Tailwind entry and adds one @source line per plugin package's src.", "files": [], "assertions": { diff --git a/skills/objectui/evals/testing.json b/skills/objectui/evals/testing.json index f16560093e5..62444573be2 100644 --- a/skills/objectui/evals/testing.json +++ b/skills/objectui/evals/testing.json @@ -26,7 +26,7 @@ "files": [], "assertions": { "must_contain": [ - "React Testing Library", + "@testing-library/react", "SchemaRendererProvider" ], "must_not_contain": [] From 73118227b6ef87b22f0d81d2cf4e730d629d425d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 21:57:21 +0000 Subject: [PATCH 3/5] wip(scenarios): self-test rows and suites for trigger cases and case files Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX --- .../qa/scenarios/src/skill-evals/self-test.ts | 110 ++++++++++- .../test/skill-evals/skill-evals.test.ts | 171 ++++++++++++++++++ 2 files changed, 276 insertions(+), 5 deletions(-) diff --git a/packages/qa/scenarios/src/skill-evals/self-test.ts b/packages/qa/scenarios/src/skill-evals/self-test.ts index bb67498666c..fa8db4ba1ba 100644 --- a/packages/qa/scenarios/src/skill-evals/self-test.ts +++ b/packages/qa/scenarios/src/skill-evals/self-test.ts @@ -17,10 +17,10 @@ import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { ApiBillingRefusedError } from '../runner/driver.js'; -import { armArgs, prepareArmWorkdir } from './arms.js'; +import { armArgs, placeCaseFiles, prepareArmWorkdir } from './arms.js'; import { loadSkillEvalCatalog, notUserInvocable, parseEvalFile, type SkillEvalCase } from './cases.js'; import { type Grader, gradeAnswer } from './grade.js'; -import { judgeTurn, preflight, regradeRecords, type SkillEvalRunRecord } from './run.js'; +import { judgeTurn, planRound, preflight, regradeRecords, type SkillEvalRunRecord } from './run.js'; import { summariseRound } from './summary.js'; /** Row label → minimum cases registered. A row is a battery; deleting one must red. */ @@ -46,10 +46,18 @@ export const SELF_TEST_BATTERIES = Object.freeze({ 'guard: ANTHROPIC_API_KEY set → the round refuses to start': 1, 'summary: no-skill ≥ with-skill is named; invalid turns stay out of the rate': 1, 'regrade: a case changed since the round → SET APART, never graded against the new text': 1, + 'reader: a trigger case reads with no assertions; one carrying assertions → REFUSED': 1, + 'reader: a `files` entry outside evals/files/ → REFUSED': 1, + 'reader: a bundle whose trigger cases are all positive → REFUSED': 1, + 'judge: a trigger case the turn loaded, by a Skill launch or a read → PASS; not loaded → FAIL': 1, + 'judge: a should-not-trigger case the turn loaded → FAIL; left alone → PASS': 1, + 'round: a trigger case runs on the with-skill arm only': 1, + 'arms: a case\'s files land in the turn\'s project on both arms': 1, + 'summary: trigger cases are tallied apart from the behaviour pass rates': 1, }); /** The roster's own size, pinned: a deleted row takes its floor with it otherwise. */ -export const SELF_TEST_BATTERY_FLOOR = 21; +export const SELF_TEST_BATTERY_FLOOR = 29; let selfTestReachedVerdict = false; /** Whether the last {@link runSelfTest} reached its verdict line. */ @@ -80,11 +88,12 @@ const fixtureCase = (over: Partial = {}): SkillEvalCase => ({ ...over, }); -/** A minimal stream-json transcript: init (with `skills`), optional Skill call, result. */ -const stream = (o: { skills: string[]; answer?: string; subtype?: string; invoked?: string }): string => +/** A minimal stream-json transcript: init (with `skills`), optional Skill call, optional Read, result. */ +const stream = (o: { skills: string[]; answer?: string; subtype?: string; invoked?: string; read?: string }): string => [ { type: 'system', subtype: 'init', model: 'fixture-model', skills: o.skills, mcp_servers: [] }, ...(o.invoked ? [{ type: 'assistant', message: { content: [{ type: 'tool_use', id: 't1', name: 'Skill', input: { skill: o.invoked } }] } }] : []), + ...(o.read ? [{ type: 'assistant', message: { content: [{ type: 'tool_use', id: 't2', name: 'Read', input: { file_path: o.read } }] } }] : []), ...(o.answer !== undefined ? [{ type: 'assistant', message: { content: [{ type: 'text', text: o.answer }] } }] : []), { type: 'result', subtype: o.subtype ?? 'success', is_error: false, num_turns: 2, result: o.answer ?? '', total_cost_usd: 0.01, duration_ms: 10, permission_denials: [] }, ] @@ -280,6 +289,97 @@ export function runSelfTest(deps: SelfTestDeps): SelfTestResult { : `expected the reworded case set apart and the unchanged one regraded, got ${out.records.length} regraded / set apart [${out.setApart.changed.join()}], then ${same.records.length} regraded`; }, }, + { + label: 'reader: a trigger case reads with no assertions; one carrying assertions → REFUSED', + run: () => { + const r = parseEvalFile('demo-skill', 't.json', JSON.stringify({ evals: [{ id: 1, prompt: 'p', should_trigger: false, files: [] }, { id: 2, prompt: 'p', should_trigger: true, assertions: { must_contain: ['x'] } }, { id: 3, prompt: 'p', should_trigger: 'yes' }] })); + return r.cases.length === 1 && r.cases[0]!.shouldTrigger === false && r.refusals.length === 2 ? true : `expected one trigger case and two refusals, got ${r.cases.length} case(s) [${r.cases.map((c) => String(c.shouldTrigger)).join()}], ${r.refusals.length} refusal(s)`; + }, + }, + { + label: 'reader: a `files` entry outside evals/files/ → REFUSED', + run: () => { + const bad = ['rules/x.md', 'evals/files/../SKILL.md', 'evals/files/', '/etc/passwd'].map((f) => parseEvalFile('demo-skill', 'f.json', JSON.stringify({ evals: [{ id: 1, prompt: 'p', files: [f], assertions: { must_contain: ['x'] } }] }))); + const good = parseEvalFile('demo-skill', 'f.json', JSON.stringify({ evals: [{ id: 1, prompt: 'p', files: ['evals/files/src/a.ts'], assertions: { must_contain: ['x'] } }] })); + return bad.every((r) => r.cases.length === 0 && r.refusals.length === 1) && good.cases[0]?.files?.join() === 'evals/files/src/a.ts' ? true : `refused ${bad.filter((r) => r.refusals.length === 1).length} of 4 bad entries; the good one read as [${good.cases[0]?.files?.join() ?? 'refused'}]`; + }, + }, + { + label: 'reader: a bundle whose trigger cases are all positive → REFUSED', + run: () => { + writeFileSync(join(fixtureRoot, 'demo-skill', 'evals', 'triggers.json'), JSON.stringify({ evals: [{ id: 1, prompt: 'p', should_trigger: true }] })); + const one = loadSkillEvalCatalog(fixtureRoot); + writeFileSync(join(fixtureRoot, 'demo-skill', 'evals', 'triggers.json'), JSON.stringify({ evals: [{ id: 1, prompt: 'p', should_trigger: true }, { id: 2, prompt: 'q', should_trigger: false }] })); + const both = loadSkillEvalCatalog(fixtureRoot); + rmSync(join(fixtureRoot, 'demo-skill', 'evals', 'triggers.json')); + return one.refusals.length === 1 && both.refusals.length === 0 && both.cases.length === 2 ? true : `expected an all-positive set refused and a mixed one read, got ${one.refusals.length} then ${both.refusals.length} refusal(s)`; + }, + }, + { + label: 'judge: a trigger case the turn loaded, by a Skill launch or a read → PASS; not loaded → FAIL', + run: () => { + const c = fixtureCase({ shouldTrigger: true, mustContain: [], mustNotContain: [] }); + const launched = judge(c, 'with-skill', stream({ skills: ['demo-skill'], invoked: 'demo-skill', answer: 'x' })); + const read = judge(c, 'with-skill', stream({ skills: ['demo-skill'], read: '/tmp/t/project/.claude/skills/demo-skill/SKILL.md', answer: 'x' })); + const otherRead = judge(c, 'with-skill', stream({ skills: ['demo-skill'], read: '/tmp/t/project/.claude/skills/demo-skill-two/SKILL.md', answer: 'x' })); + const none = judge(c, 'with-skill', stream({ skills: ['demo-skill'], answer: GOOD })); + return launched.verdict === 'pass' && launched.trigger?.loadedBy.join() === 'skill-tool' && read.verdict === 'pass' && read.trigger?.loadedBy.join() === 'read' && otherRead.verdict === 'fail' && none.verdict === 'fail' + ? true + : `expected pass/pass/fail/fail, got ${launched.verdict}/${read.verdict}/${otherRead.verdict}/${none.verdict}`; + }, + }, + { + label: 'judge: a should-not-trigger case the turn loaded → FAIL; left alone → PASS', + run: () => { + const c = fixtureCase({ shouldTrigger: false, mustContain: [], mustNotContain: [] }); + const loaded = judge(c, 'with-skill', stream({ skills: ['demo-skill'], invoked: 'demo-skill', answer: 'x', subtype: 'error_max_turns' })); + const alone = judge(c, 'with-skill', stream({ skills: ['demo-skill'], answer: 'x' })); + const cut = judge(c, 'with-skill', stream({ skills: ['demo-skill'], answer: 'x', subtype: 'error_max_turns' })); + return loaded.verdict === 'fail' && alone.verdict === 'pass' && cut.verdict === 'error' ? true : `expected fail/pass/error, got ${loaded.verdict}/${alone.verdict}/${cut.verdict}`; + }, + }, + { + label: 'round: a trigger case runs on the with-skill arm only', + run: () => { + const jobs = planRound([fixtureCase(), fixtureCase({ id: 2, key: 'demo-skill/demo#2', shouldTrigger: true, mustContain: [] })], 1); + const onNoSkill = judge(fixtureCase({ shouldTrigger: true, mustContain: [] }), 'no-skill', stream({ skills: [], answer: 'x' })); + const arms = jobs.map((j) => `${String(j.case.id)}:${j.arm}`).join(); + return arms === '1:with-skill,1:no-skill,2:with-skill' && onNoSkill.verdict === 'invalid' ? true : `planned [${arms}]; a no-skill trigger turn read ${onNoSkill.verdict}`; + }, + }, + { + label: 'arms: a case\'s files land in the turn\'s project on both arms', + run: () => { + mkdirSync(join(fixtureRoot, 'demo-skill', 'evals', 'files', 'src'), { recursive: true }); + writeFileSync(join(fixtureRoot, 'demo-skill', 'evals', 'files', 'src', 'task.object.ts'), 'export {};\n'); + const ok = (['with-skill', 'no-skill'] as const).every((arm) => { + const d = prepareArmWorkdir(arm, 'demo-skill', fixtureRoot); + placeCaseFiles(['evals/files/src'], 'demo-skill', fixtureRoot, d.cwd); + const placed = existsSync(join(d.cwd, 'src', 'task.object.ts')) && !existsSync(join(d.cwd, 'evals')); + rmSync(d.root, { recursive: true, force: true }); + return placed; + }); + rmSync(join(fixtureRoot, 'demo-skill', 'evals', 'files'), { recursive: true, force: true }); + return ok ? true : 'a case file did not land at its path below evals/files/ on both arms'; + }, + }, + { + label: 'summary: trigger cases are tallied apart from the behaviour pass rates', + run: () => { + const b = fixtureCase(); + const pos = fixtureCase({ id: 2, key: 'demo-skill/demo#2', shouldTrigger: true, mustContain: [] }); + const neg = fixtureCase({ id: 3, key: 'demo-skill/demo#3', shouldTrigger: false, mustContain: [] }); + const s = summariseRound( + [b, pos, neg], + [judge(b, 'with-skill', stream({ skills: ['demo-skill'], answer: GOOD })), judge(pos, 'with-skill', stream({ skills: ['demo-skill'], answer: 'x' })), judge(neg, 'with-skill', stream({ skills: ['demo-skill'], invoked: 'demo-skill', answer: 'x' }))], + [], + ); + const t = s.triggers.bundles[0]; + return s.cases.length === 1 && s.totals.withSkill.pass === 1 && s.totals.withSkill.fail === 0 && t?.missedLoads.join() === pos.key && t.falseLoads.join() === neg.key && s.triggers.cases.length === 2 + ? true + : `behaviour cases ${s.cases.length} (with-skill ${s.totals.withSkill.pass}/${s.totals.withSkill.fail}); missed [${t?.missedLoads.join() ?? ''}], false [${t?.falseLoads.join() ?? ''}]`; + }, + }, ]; let failed = 0; diff --git a/packages/qa/scenarios/test/skill-evals/skill-evals.test.ts b/packages/qa/scenarios/test/skill-evals/skill-evals.test.ts index 6a6168fb572..ec36836bcff 100644 --- a/packages/qa/scenarios/test/skill-evals/skill-evals.test.ts +++ b/packages/qa/scenarios/test/skill-evals/skill-evals.test.ts @@ -8,6 +8,7 @@ * every catalog is a fixture written here. */ +import { createHash } from 'node:crypto'; import { chmodSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; @@ -395,3 +396,173 @@ describe('--regrade grades an old answer only against the case that ran', () => expect(md).not.toContain('| alpha-skill/cases#2 |'); }); }); + +describe('trigger cases: graded on whether the with-skill turn loaded the bundle, reported beside the behaviour cases', () => { + const view = { bundles: ['alpha-skill', 'beta-skill'], unlisted: [] }; + const pos: SkillEvalCase = { bundle: 'alpha-skill', file: 'triggers.json', id: 1, key: 'alpha-skill/triggers#1', prompt: 'design an object', mustContain: [], mustNotContain: [], shouldTrigger: true }; + const neg: SkillEvalCase = { ...pos, id: 2, key: 'alpha-skill/triggers#2', prompt: 'a near miss', shouldTrigger: false }; + /** A stream whose turn launched `invoked` with the Skill tool and/or read `read`. */ + const turn = (o: { invoked?: string; read?: string; subtype?: string }) => { + const [init, ...rest] = stream({ skills: ['alpha-skill'], answer: 'an answer', ...(o.subtype ? { subtype: o.subtype } : {}) }).split('\n'); + const calls = [ + ...(o.invoked ? [{ type: 'tool_use', id: 's', name: 'Skill', input: { skill: o.invoked } }] : []), + ...(o.read ? [{ type: 'tool_use', id: 'r', name: 'Read', input: { file_path: o.read } }] : []), + ]; + return exited([init, ...(calls.length ? [JSON.stringify({ type: 'assistant', message: { content: calls } })] : []), ...rest].join('\n')); + }; + const judgeT = (c: SkillEvalCase, run: TurnProcessRun, arm: 'with-skill' | 'no-skill' = 'with-skill') => judgeTurn(c, arm, 1, run, view, 't'); + + it('the reader takes `should_trigger` in place of `assertions`, and refuses a trigger case carrying both or a non-boolean kind', () => { + const r = parseEvalFile('alpha-skill', 'triggers.json', JSON.stringify({ evals: [ + { id: 1, prompt: 'p', should_trigger: true, files: [] }, + { id: 2, prompt: 'q', should_trigger: false }, + { id: 3, prompt: 'r', should_trigger: true, assertions: { must_contain: ['x'] } }, + { id: 4, prompt: 's', should_trigger: 1 }, + ] })); + expect(r.cases.map((c) => [c.id, c.shouldTrigger, c.mustContain.length, c.mustNotContain.length])).toEqual([[1, true, 0, 0], [2, false, 0, 0]]); + expect(r.refusals.map((x) => x.path)).toEqual(['alpha-skill/evals/triggers.json: evals[2]', 'alpha-skill/evals/triggers.json: evals[3]']); + expect(r.refusals[0]!.message).toMatch(/graded on whether the skill was loaded/); + }); + + it('the catalog refuses a bundle whose trigger cases are all of one kind', () => { + const root = writeCatalog(); + const write = (evals: unknown[]) => writeFileSync(join(root, 'alpha-skill', 'evals', 'triggers.json'), JSON.stringify({ evals })); + write([{ id: 1, prompt: 'p', should_trigger: true }, { id: 2, prompt: 'q', should_trigger: true }]); + expect(loadSkillEvalCatalog(root).refusals).toEqual([{ path: 'alpha-skill/evals', message: expect.stringMatching(/every trigger case is positive/) }]); + write([{ id: 1, prompt: 'p', should_trigger: false }]); + expect(loadSkillEvalCatalog(root).refusals[0]?.message).toMatch(/every trigger case is negative/); + write([{ id: 1, prompt: 'p', should_trigger: true }, { id: 2, prompt: 'q', should_trigger: false }]); + const cat = loadSkillEvalCatalog(root); + expect(cat.refusals).toEqual([]); + expect(cat.cases.filter((c) => c.shouldTrigger !== undefined).map((c) => c.key)).toEqual(['alpha-skill/triggers#1', 'alpha-skill/triggers#2']); + }); + + it('loaded = a Skill launch of the bundle or a Read under its .claude/skills/ directory; pass = loaded as should_trigger says', () => { + expect(judgeT(pos, turn({ invoked: 'alpha-skill' }))).toMatchObject({ verdict: 'pass', trigger: { shouldTrigger: true, loadedBy: ['skill-tool'] }, missing: [], forbidden: [] }); + expect(judgeT(pos, turn({ read: '/tmp/skill-eval-x/project/.claude/skills/alpha-skill/rules/a.md' }))).toMatchObject({ verdict: 'pass', trigger: { loadedBy: ['read'] }, skillFilesRead: ['alpha-skill/rules/a.md'] }); + expect(judgeT(pos, turn({ invoked: 'alpha-skill', read: 'C:\\t\\project\\.claude\\skills\\alpha-skill\\SKILL.md' })).trigger?.loadedBy).toEqual(['skill-tool', 'read']); + // Another skill launched, or a file of a same-prefix bundle read, is not this bundle loaded. + expect(judgeT(pos, turn({ invoked: 'debug', read: '/t/project/.claude/skills/alpha-skill-two/SKILL.md' }))).toMatchObject({ verdict: 'fail', trigger: { loadedBy: [] } }); + expect(judgeT(neg, turn({}))).toMatchObject({ verdict: 'pass', trigger: { shouldTrigger: false, loadedBy: [] } }); + expect(judgeT(neg, turn({ invoked: 'alpha-skill' })).verdict).toBe('fail'); + }); + + it('a loaded turn is judged however it ended; an unloaded one cut short is an error; the no-skill arm is invalid', () => { + expect(judgeT(neg, turn({ invoked: 'alpha-skill', subtype: 'error_max_turns' })).verdict).toBe('fail'); + expect(judgeT(pos, turn({ read: '/t/project/.claude/skills/alpha-skill/SKILL.md', subtype: 'error_max_turns' })).verdict).toBe('pass'); + expect(judgeT(pos, turn({ subtype: 'error_max_turns' }))).toMatchObject({ verdict: 'error', reason: expect.stringMatching(/without loading the bundle/) }); + expect(judgeT(pos, exited(stream({ skills: [], answer: 'x' })), 'no-skill')).toMatchObject({ verdict: 'invalid', reason: 'a trigger case runs on the with-skill arm only' }); + expect(judgeT(pos, exited(stream({ skills: ['debug'], answer: 'x' }))).verdict).toBe('invalid'); + }); + + it('a behaviour case hashes as before; a trigger case and a case with files hash their extra fields', () => { + const b: SkillEvalCase = { bundle: 'alpha-skill', file: 'cases.json', id: 1, key: 'alpha-skill/cases#1', prompt: 'p', mustContain: ['x'], mustNotContain: [] }; + expect(hashCase(b)).toBe(`sha256:${createHash('sha256').update(JSON.stringify(['p', ['x'], []])).digest('hex')}`); + expect(hashCase({ ...b, files: [] })).toBe(hashCase(b)); + expect(hashCase({ ...b, files: ['evals/files/a.ts'] })).not.toBe(hashCase(b)); + expect(hashCase(pos)).not.toBe(hashCase(neg)); + expect(hashCase(pos)).not.toBe(hashCase({ ...neg, prompt: pos.prompt })); + }); + + it('a round runs a trigger case on the with-skill arm only; the summary tallies it apart from the behaviour rates', async () => { + const root = writeCatalog(); + writeFileSync(join(root, 'alpha-skill', 'evals', 'triggers.json'), JSON.stringify({ evals: [{ id: 1, prompt: 'load me', should_trigger: true }, { id: 2, prompt: 'leave me', should_trigger: false }] })); + const cat = loadSkillEvalCatalog(root); + const cases = selectBundles(cat, ['alpha-skill']); + const seen: string[] = []; + const exec = await executeRound(planRound(cases, 1), { + bin: 'claude', skillsRoot: root, catalog: { bundles: cat.bundles, unlisted: cat.unlistedBundles }, outDir: mkdtempSync(join(scratch, 'out-')), maxTurns: 5, caseTimeoutMs: 1000, concurrency: 1, maxUtilization: 0.9, + runTurn: async (_bin, _args, o) => { + const skillsDir = join(o.cwd, '.claude', 'skills'); + const skills = existsSync(skillsDir) ? readdirSync(skillsDir) : []; + seen.push(`${o.input}|${skills.join()}`); + // The model launches the skill on every prompt: right for `load me`, a false load for `leave me`. + const [init, ...rest] = stream({ skills, answer: '$icontains orderBy' }).split('\n'); + const launch = skills.length ? [JSON.stringify({ type: 'assistant', message: { content: [{ type: 'tool_use', id: 's', name: 'Skill', input: { skill: 'alpha-skill' } }] } })] : []; + return exited([init, ...launch, ...rest].join('\n')); + }, + }); + expect(seen).toEqual(['prompt 1|alpha-skill', 'prompt 1|', 'prompt 2|alpha-skill', 'prompt 2|', 'load me|alpha-skill', 'leave me|alpha-skill']); + const s = summariseRound(cases, exec.records, exec.notRun); + expect(s.cases.map((c) => c.key)).toEqual(['alpha-skill/cases#1', 'alpha-skill/cases#2']); + expect(s.totals.withSkill).toMatchObject({ pass: 2, fail: 0 }); + expect(s.triggers.bundles).toEqual([expect.objectContaining({ bundle: 'alpha-skill', cases: 2, missedLoads: [], falseLoads: ['alpha-skill/triggers#2'] })]); + expect(s.triggers.totals.shouldTrigger).toMatchObject({ pass: 1, fail: 0, rate: 1 }); + expect(s.triggers.totals.shouldNotTrigger).toMatchObject({ pass: 0, fail: 1, rate: 0 }); + expect(s.triggers.cases.map((t) => [t.key, t.loadedBySkillTool, t.loadedByReadOnly])).toEqual([['alpha-skill/triggers#1', 1, 0], ['alpha-skill/triggers#2', 1, 0]]); + const md = renderSummaryMarkdown(s, { title: 'T', lines: [] }); + expect(md).toContain('## Trigger cases'); + expect(md).toContain('| alpha-skill | 2 | 1/1 (100%) | 0/1 (0%) | 0 | 1 | 0 |'); + expect(md).toContain('| alpha-skill/triggers#2 | no | 0/1 (0%) | 1 / 0 |'); + // A round with no trigger case renders no trigger section. + expect(renderSummaryMarkdown(summariseRound([], [], []), { title: 'T', lines: [] })).not.toContain('## Trigger cases'); + }); + + it('--regrade keeps a recorded trigger case planned and regrades it from its record', async () => { + const root = writeCatalog(); + writeFileSync(join(root, 'beta-skill', 'evals', 'triggers.json'), JSON.stringify({ evals: [{ id: 1, prompt: 'load me', should_trigger: true }, { id: 2, prompt: 'leave me', should_trigger: false }] })); + const cat = loadSkillEvalCatalog(root); + const dir = mkdtempSync(join(scratch, 'round-')); + const exec = await executeRound(planRound(cat.cases, 1), { + bin: 'claude', skillsRoot: root, catalog: { bundles: cat.bundles, unlisted: cat.unlistedBundles }, outDir: dir, maxTurns: 5, caseTimeoutMs: 1000, concurrency: 1, maxUtilization: 0.9, + runTurn: async (_bin, _args, o) => { + const skillsDir = join(o.cwd, '.claude', 'skills'); + return exited(stream({ skills: existsSync(skillsDir) ? readdirSync(skillsDir) : [], answer: 'orderBy defineView $icontains' })); + }, + }); + const summary = summariseRound(cat.cases, exec.records, []); + writeFileSync(join(dir, 'round.json'), JSON.stringify({ schema: ROUND_RECORD_SCHEMA, round: 'r', runner: { repo: 'x', sha: 'y' }, startedAt: 't', finishedAt: 't', wallMs: 1, skills: { source: 'workspace skills/', bundles: cat.bundles, allBundles: true }, driver: { driver: 'claude-code-cli', version: 'v', authMethod: 'oauth_token', apiBilled: false, servedModels: [], maxTurns: 5, caseTimeoutMs: 1, concurrency: 1, maxUtilization: 0.9 }, scope: { cases: 5, arms: ['with-skill', 'no-skill'], repeats: 1, plannedTurns: 8, ranTurns: 8, notRunTurns: 0 }, summary })); + const log = vi.spyOn(console, 'log').mockImplementation(() => {}); + try { + expect(regradeRound(dir, loadSkillEvalCatalog(root), 'workspace skills/')).toBe(0); + } finally { + log.mockRestore(); + } + const round = JSON.parse(readFileSync(join(dir, 'round.json'), 'utf8')) as { regraded: { added: string[] }; summary: { triggers: { cases: Array<{ key: string; tally: { pass: number; fail: number } }> } } }; + expect(round.regraded.added).toEqual([]); + expect(round.summary.triggers.cases.map((t) => [t.key, t.tally.pass, t.tally.fail])).toEqual([['beta-skill/triggers#1', 0, 1], ['beta-skill/triggers#2', 1, 0]]); + }); +}); + +describe('`files`: what a case needs on disk, placed in the turn\'s project on both arms', () => { + it('the reader takes paths under evals/files/ only', () => { + const read = (files: unknown) => parseEvalFile('alpha-skill', 'f.json', JSON.stringify({ evals: [{ id: 1, prompt: 'p', files, assertions: { must_contain: ['x'] } }] })); + expect(read(['evals/files/src/objects/task.object.ts', 'evals/files/crm']).cases[0]?.files).toEqual(['evals/files/src/objects/task.object.ts', 'evals/files/crm']); + expect(read([]).cases[0]?.files).toBeUndefined(); + for (const bad of [['src/a.ts'], ['evals/files/'], ['evals/files/../SKILL.md'], ['evals/files/./a.ts'], ['evals\\files\\a.ts'], ['/evals/files/a.ts'], 'evals/files/a.ts', [1]]) { + expect(read(bad).cases, JSON.stringify(bad)).toEqual([]); + } + }); + + it('the catalog refuses a case naming a file the bundle lacks; a round places each file below evals/files/ in both arms\' projects', async () => { + const root = writeCatalog(); + const evalsFile = join(root, 'alpha-skill', 'evals', 'cases.json'); + const doc = JSON.parse(readFileSync(evalsFile, 'utf8')) as { evals: Array<{ files: string[] }> }; + doc.evals[0]!.files = ['evals/files/src/objects/task.object.ts', 'evals/files/docs']; + writeFileSync(evalsFile, JSON.stringify(doc)); + expect(loadSkillEvalCatalog(root).refusals).toEqual([{ path: 'alpha-skill/evals/cases.json: alpha-skill/cases#1', message: expect.stringMatching(/`evals\/files\/src\/objects\/task.object.ts`, which is not in the bundle/) }]); + mkdirSync(join(root, 'alpha-skill', 'evals', 'files', 'src', 'objects'), { recursive: true }); + mkdirSync(join(root, 'alpha-skill', 'evals', 'files', 'docs'), { recursive: true }); + writeFileSync(join(root, 'alpha-skill', 'evals', 'files', 'src', 'objects', 'task.object.ts'), 'export const task = 1;\n'); + writeFileSync(join(root, 'alpha-skill', 'evals', 'files', 'docs', 'guide.md'), '# guide\n'); + const cat = loadSkillEvalCatalog(root); + expect(cat.refusals).toEqual([]); + const placed: string[][] = []; + await executeRound(planRound(selectBundles(cat, ['alpha-skill']).slice(0, 1), 1), { + bin: 'claude', skillsRoot: root, catalog: { bundles: cat.bundles, unlisted: cat.unlistedBundles }, outDir: mkdtempSync(join(scratch, 'out-')), maxTurns: 5, caseTimeoutMs: 1000, concurrency: 1, maxUtilization: 0.9, + runTurn: async (_bin, _args, o) => { + placed.push([ + readFileSync(join(o.cwd, 'src', 'objects', 'task.object.ts'), 'utf8'), + readFileSync(join(o.cwd, 'docs', 'guide.md'), 'utf8'), + String(existsSync(join(o.cwd, 'evals'))), + String(existsSync(join(o.cwd, '.claude'))), + ]); + return exited(stream({ skills: existsSync(join(o.cwd, '.claude')) ? ['alpha-skill'] : [], answer: '$icontains' })); + }, + }); + expect(placed).toEqual([ + ['export const task = 1;\n', '# guide\n', 'false', 'true'], + ['export const task = 1;\n', '# guide\n', 'false', 'false'], + ]); + }); +}); From 75fc7048b0e0cfdbe3e287909ba0a28177911eab Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 22:07:14 +0000 Subject: [PATCH 4/5] wip: changeset and README for skill-evals trigger cases Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX --- .changeset/34789-skill-evals-trigger-cases.md | 13 +++++++++++++ packages/qa/scenarios/README.md | 18 +++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 .changeset/34789-skill-evals-trigger-cases.md diff --git a/.changeset/34789-skill-evals-trigger-cases.md b/.changeset/34789-skill-evals-trigger-cases.md new file mode 100644 index 00000000000..50d6ceefabc --- /dev/null +++ b/.changeset/34789-skill-evals-trigger-cases.md @@ -0,0 +1,13 @@ +--- +'@objectstack/scenarios': patch +'@objectstack/skills': patch +--- + +docs(skills): trigger cases for the six metadata skills, and eval cases that grade the skill instead of a spelling or a missing project + +Clause-②: no +Metadata-protocol: none + +`@objectstack/skills` ships each bundle's `evals/` as eval fixtures, inert in a consumer install. The six metadata skills (`objectstack-data`, `-query`, `-ui`, `-automation`, `-formula`, `-i18n`) each gain `evals/triggers.json`: 42 trigger cases, 12 of them near misses that should leave the skill alone. A trigger case carries `should_trigger: true | false` in place of `assertions` and is graded on whether the skill was loaded. Eleven existing cases had an assertion bound to one spelling of a right answer, or forbidding a token a right answer quotes; those assertions are narrowed. Thirty prompts that read as if a project were on disk now state that none is and what the answer should carry. + +The `@objectstack/scenarios` README documents how the checkout-only `skill-evals` runner grades and reports trigger cases and places a case's `files`. The runner is not in the package's published `bin` or `exports`, so nothing a consumer installs changes beyond the README text. diff --git a/packages/qa/scenarios/README.md b/packages/qa/scenarios/README.md index 5519cfaf9de..65ff67e55a8 100644 --- a/packages/qa/scenarios/README.md +++ b/packages/qa/scenarios/README.md @@ -736,8 +736,8 @@ wrapper, with no change to the runner. Every published skill bundle carries eval cases (`skills/BUNDLE/evals/*.json`: a `prompt`, an `expected_output` and `assertions.must_contain` / `must_not_contain`). `skill-evals` sends each case to the local Claude Code login twice, -once with the bundle installed and once without, and grades each answer by the case's own tokens. It runs from this -checkout only. It is not part of the published `bin` or `exports`, not a CI job and not a merge gate. The cases are +once with the bundle installed and once without, and grades each answer by the case's own tokens. A trigger case +asks instead whether the skill was loaded, and runs with the bundle installed only. It runs from this checkout only. It is not part of the published `bin` or `exports`, not a CI job and not a merge gate. The cases are the skill authors' and the runner never edits them. ```bash @@ -770,6 +770,18 @@ pnpm --filter @objectstack/scenarios skill-evals --self-test # the runner's o record's `armEvidence` says whether the turn launched the bundle (`launched`) or nothing in the stream shows it (`not-shown`). A turn with no answer is `error`: the process failed or timed out, or the result line is not `success` (`error_max_turns` included). Both kinds are counted and named, and neither is in a denominator. +- **Trigger cases**: an entry with `"should_trigger": true | false` in place of `assertions` (the reader refuses one + carrying both) asks whether the skill was loaded when it should be and left alone when it should not. It runs on + the with-skill arm only and is graded on the turn, never on its answer: the turn loaded the bundle when it launched + it with the `Skill` tool or read a file under its `.claude/skills/BUNDLE/` (the record's `trigger.loadedBy` says + which), and the case passes when that matches `should_trigger`. A turn that loaded the bundle is judged however it + ended; one that did not is judged only when it ended `success`, and is `error` otherwise. A bundle whose trigger + cases are all positive, or all negative, is refused. The summary reports trigger cases in their own section beside + the behaviour cases, never inside their pass rates: per bundle, loaded when it should, left alone when it should + not, the missed loads and the false loads. +- **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). 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. `--regrade DIR` applies the current rules to a recorded round's answers and arm facts. A changed record keeps the verdict its turn was first given as `regradedFrom`. Each record carries `caseHash`, a hash of its case's prompt and token lists as the turn ran them. A case changed or removed since the round is set apart: it is not regraded, its @@ -777,7 +789,7 @@ pnpm --filter @objectstack/scenarios skill-evals --self-test # the runner's o hash; it is regraded against the case as it is now, and the summary counts it as unhashed. - **Records**: by default the round goes to `docs/qa/platform-checklist/runs/skill-evals/ROUND/` (git-ignored), or to `--out`. It holds one `runs/*.json` per turn (verdict, missing and forbidden tokens, the answer, the skills listed - and launched, the served model, the CLI's notional cost and the rate-limit reading), `round.json` (environment, + and launched, the skill files read, the served model, the CLI's notional cost and the rate-limit reading), `round.json` (environment, scope and the full per-case scores on both arms) and `summary.md`. The summary has one row per bundle (each arm's pass rate, the with-skill failing cases, and the cases where the no-skill arm scored at least as high) and then every case. `summary.github.md` is the same text with angle brackets spelled `(lt)` / `(gt)` for a GitHub body. From c169dc85d571ae167e6dd63d5774a017cb07c987 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 23:37:13 +0000 Subject: [PATCH 5/5] fix(scenarios): refuse skill-eval case files that land under .claude/ A `files` entry is copied into both arms' projects, and `.claude/` is where Claude Code finds skills, so a case file there could hand the no-skill arm a skill without the turn being called invalid. caseFileProblem now refuses any `.claude` segment below evals/files/, at any depth and in any letter case. Adds a test and a self-test row (floor 29 -> 30). Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX --- packages/qa/scenarios/README.md | 2 +- packages/qa/scenarios/src/skill-evals/cases.ts | 9 ++++++++- packages/qa/scenarios/src/skill-evals/self-test.ts | 12 +++++++++++- .../scenarios/test/skill-evals/skill-evals.test.ts | 12 ++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/packages/qa/scenarios/README.md b/packages/qa/scenarios/README.md index 65ff67e55a8..6152576c6bc 100644 --- a/packages/qa/scenarios/README.md +++ b/packages/qa/scenarios/README.md @@ -780,7 +780,7 @@ pnpm --filter @objectstack/scenarios skill-evals --self-test # the runner's o the behaviour cases, never inside their pass rates: per bundle, loaded when it should, left alone when it should not, the missed loads and the false loads. - **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). Each is copied, a directory whole, into both arms' directories at its path below + 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. `--regrade DIR` applies the current rules to a recorded round's answers and arm facts. A changed record keeps the verdict its turn was first given as `regradedFrom`. Each record carries `caseHash`, a hash of its case's prompt and diff --git a/packages/qa/scenarios/src/skill-evals/cases.ts b/packages/qa/scenarios/src/skill-evals/cases.ts index 37f04b9e38c..e5f089ae1d1 100644 --- a/packages/qa/scenarios/src/skill-evals/cases.ts +++ b/packages/qa/scenarios/src/skill-evals/cases.ts @@ -109,12 +109,19 @@ export const hashCase = (c: Pick p === '' || p === '.' || p === '..')) { return `\`files\` entry \`${entry}\` is not a path under \`${CASE_FILES_DIR}/\` (forward slashes, no \`.\` or \`..\` segment)`; } + // Both arms receive every case file, and `.claude/` is where Claude Code finds + // skills: a case file there would hand the no-skill arm a skill without + // `verdictOf` ever calling the turn invalid. Any depth, any letter case (a + // case-insensitive disk resolves `.Claude` to the same directory). + if (parts.slice(2).some((p) => p.toLowerCase() === '.claude')) { + return `\`files\` entry \`${entry}\` would land under a \`.claude/\` directory in the turn's project, which only the runner fills: a case file there reaches the no-skill arm too`; + } return undefined; } diff --git a/packages/qa/scenarios/src/skill-evals/self-test.ts b/packages/qa/scenarios/src/skill-evals/self-test.ts index 21c45347404..3ad0ee4bd10 100644 --- a/packages/qa/scenarios/src/skill-evals/self-test.ts +++ b/packages/qa/scenarios/src/skill-evals/self-test.ts @@ -48,6 +48,7 @@ export const SELF_TEST_BATTERIES = Object.freeze({ 'regrade: a case changed since the round → SET APART, never graded against the new text': 1, 'reader: a trigger case reads with no assertions; one carrying assertions → REFUSED': 1, 'reader: a `files` entry outside evals/files/ → REFUSED': 1, + 'reader: a `files` entry that would land under the project\'s .claude/ → REFUSED': 1, 'reader: a bundle whose trigger cases are all positive → REFUSED': 1, 'judge: a trigger case the turn loaded, by a Skill launch or a read → PASS; not loaded → FAIL': 1, 'judge: a should-not-trigger case the turn loaded → FAIL; left alone → PASS': 1, @@ -57,7 +58,7 @@ export const SELF_TEST_BATTERIES = Object.freeze({ }); /** The roster's own size, pinned: a deleted row takes its floor with it otherwise. */ -export const SELF_TEST_BATTERY_FLOOR = 29; +export const SELF_TEST_BATTERY_FLOOR = 30; let selfTestReachedVerdict = false; /** Whether the last {@link runSelfTest} reached its verdict line. */ @@ -304,6 +305,15 @@ export function runSelfTest(deps: SelfTestDeps): SelfTestResult { return bad.every((r) => r.cases.length === 0 && r.refusals.length === 1) && good.cases[0]?.files?.join() === 'evals/files/src/a.ts' ? true : `refused ${bad.filter((r) => r.refusals.length === 1).length} of 4 bad entries; the good one read as [${good.cases[0]?.files?.join() ?? 'refused'}]`; }, }, + { + label: 'reader: a `files` entry that would land under the project\'s .claude/ → REFUSED', + run: () => { + const read = (f: string) => parseEvalFile('demo-skill', 'f.json', JSON.stringify({ evals: [{ id: 1, prompt: 'p', files: [f], assertions: { must_contain: ['x'] } }] })); + const bad = ['evals/files/.claude/skills/demo-skill/SKILL.md', 'evals/files/.claude', 'evals/files/.Claude/skills/x/SKILL.md', 'evals/files/app/.claude/skills/x/SKILL.md'].map(read); + const good = read('evals/files/.claude-notes.md'); + return bad.every((r) => r.cases.length === 0 && r.refusals.length === 1) && good.cases.length === 1 ? true : `refused ${bad.filter((r) => r.refusals.length === 1).length} of 4 .claude entries; .claude-notes.md read as ${good.cases.length === 1 ? 'a case' : 'refused'}`; + }, + }, { label: 'reader: a bundle whose trigger cases are all positive → REFUSED', run: () => { diff --git a/packages/qa/scenarios/test/skill-evals/skill-evals.test.ts b/packages/qa/scenarios/test/skill-evals/skill-evals.test.ts index c41010d6c45..6909e85e927 100644 --- a/packages/qa/scenarios/test/skill-evals/skill-evals.test.ts +++ b/packages/qa/scenarios/test/skill-evals/skill-evals.test.ts @@ -540,6 +540,18 @@ describe('`files`: what a case needs on disk, placed in the turn\'s project on b } }); + it('the reader refuses a path that would land under the project\'s .claude/, where only the runner puts a skill', () => { + const read = (files: string[]) => parseEvalFile('alpha-skill', 'f.json', JSON.stringify({ evals: [{ id: 1, prompt: 'p', files, assertions: { must_contain: ['x'] } }] })); + for (const bad of ['evals/files/.claude/skills/alpha-skill/SKILL.md', 'evals/files/.claude', 'evals/files/.claude/settings.json', 'evals/files/.CLAUDE/skills/x/SKILL.md', 'evals/files/app/.claude/skills/x/SKILL.md']) { + const r = read([bad]); + expect(r.cases, bad).toEqual([]); + expect(r.refusals, bad).toEqual([{ path: 'alpha-skill/evals/f.json: evals[0]', message: expect.stringContaining('`.claude/`') }]); + } + for (const good of ['evals/files/.claude-notes.md', 'evals/files/claude/a.md', 'evals/files/.mcp.json']) { + expect(read([good]).cases[0]?.files, good).toEqual([good]); + } + }); + it('the catalog refuses a case naming a file the bundle lacks; a round places each file below evals/files/ in both arms\' projects', async () => { const root = writeCatalog(); const evalsFile = join(root, 'alpha-skill', 'evals', 'cases.json');