Skip to content

Commit 62da8a3

Browse files
feat(skills): trigger cases for the six metadata skills; eval assertions and prompts that grade the skill (#35022)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBFyg5B2muWbKZjA9phXVWse)_ repo:objectstack#3 · os-support-ai · session_01WGufzfr1xZSFZzCR8HnqXX Round 2 (`c169dc85d5`, after L1-e's review and the seat's contract review): the reader refuses a `files` entry that would land under a `.claude/` directory, and the trigger-case paragraph below now describes the query and i18n negatives as they are. Part of #34789. This PR is the cases and the runner's grading of trigger cases. The card's done-when also needs a model round and #34769 judged on the trigger cases. The round has since run on this PR's runner and cases (`claude-haiku-5-5`, effort medium, at `8d82dcb937`, 476 of 476 turns) and its trigger results are posted as the before baseline for #34769; judging #34769 is still owed, so the card stays open. Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:六个元数据技能(data、query、ui、automation、formula、i18n)各加 7 条触发用例,共 42 条,其中 12 条是不该加载技能的近似请求;`skill-evals` 运行器按“这一轮是否加载了技能”给触发用例打分,只跑装了技能的一臂,并在汇总里单列。另有 11 条已有用例的断言放宽成任何正确答案都能过;30 条提示词写明“当前目录没有项目文件”及答题所需的上下文;运行器开始支持用例的 `files`,并拒收会落到项目 `.claude/` 下的路径(否则无技能一臂也可能拿到技能)。 - **为什么改**:#34691 S2 裁定 A,本卡是 #34764 留下的那部分。上一轮跑出的失败里,有的只因断言要求某一种写法,有的只因提示词假设磁盘上有项目,与技能无关;而 #34769 改技能描述,需要触发用例才能比较改前改后。 - **风险与回滚**:只动评测用例(随 `@objectstack/skills` 发布,但在使用者项目里不起作用)和只能从检出运行的运行器,不进 CI,不拦合并,dist 里查不到新符号(已实测)。没改的用例哈希不变,旧轮次照常 `--regrade`;改过的 41 条在旧轮次重评时会被单列、不计入通过率。回滚即 revert 本 PR。 - **先看**:`packages/qa/scenarios/src/skill-evals/run.ts`(`verdictOf` 的触发分支和 `loadEvidence`,风险最高:判定“加载”的口径);`skills/objectstack-data/evals/triggers.json`(触发用例的形状和反例的选法);`packages/qa/scenarios/src/skill-evals/cases.ts`(读取器的拒收规则)。 - **两分钟验证**:`pnpm --filter @objectstack/scenarios skill-evals --dry-run`,应看到 `217 behaviour case(s) × 2 arms + 42 trigger case(s) × the with-skill arm, × 1 = 476 turn(s)` 和 `30 should load the bundle, 12 should not`。 - **需要你做的**:本 PR 改了 `skills/**`(受管面 Tier H),请审批;落地由席位完成。 ## What changes **Trigger cases (scope item 3).** The six metadata skills named by #34769 (`objectstack-data`, `objectstack-query`, `objectstack-ui`, `objectstack-automation`, `objectstack-formula`, `objectstack-i18n`) each gain `evals/triggers.json`: 7 cases each, 42 in all, 12 negative (29 percent; the card asks for at least one in ten). Each bundle has 5 positives (two phrased as building over MCP with no project files, the phrasing #34769 targets; two plain intents; one in Chinese) and 2 negatives. In four bundles (`objectstack-data`, `objectstack-ui`, `objectstack-automation`, `objectstack-formula`) the pair is a neighbouring skill's task inside ObjectStack, which a "Not for" clause should send elsewhere, and a near miss outside ObjectStack. `objectstack-query`'s two are both neighbouring-skill tasks inside ObjectStack: a select field on `ticket` (data) and a filtered list view on `ticket` (ui). `objectstack-i18n`'s two are both near misses outside ObjectStack: react-i18next in a plain React app, and `Intl.NumberFormat` in a Node.js script. The shape is the existing case entry with `"should_trigger": true | false` in place of `assertions`: `{ "id", "prompt", "should_trigger", "files": [] }`. The runner (`packages/qa/scenarios/src/skill-evals/`): - reads it strictly. A trigger case carrying `assertions`, a non-boolean `should_trigger`, and a bundle whose trigger cases are all of one kind are refused with a location; - plans it on the with-skill arm only, since nothing can be loaded without the bundle; - grades it on the turn, never the 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. The card's round saw the model reach skill text by reading files more often than by the `Skill` tool, so both count, and the summary shows them apart. A turn that loaded the bundle is judged however it ended. One that did not is judged only on a `success` result, and is `error` otherwise (out of the denominator), because a turn cut short may have been about to load it; - reports trigger cases in their own summary section beside the behaviour cases and never inside their pass rates: per bundle, loaded when it should, left alone when it should not, missed loads and false loads, and per case the Skill-tool or read-only split. `--regrade` keeps trigger cases planned and regrades them from the records; - records `skillFilesRead` on every turn, behaviour cases included. `hashCase` adds the trigger kind and a non-empty `files` list only when a case has them, so every unchanged behaviour case keeps its hash and old rounds regrade as before. **`files` (scope item 2).** `files` was read by nothing. An entry is now a path under the bundle's `evals/files/`; the reader refuses anything else, and the catalog refuses a path the bundle lacks. The reader also refuses an entry with a `.claude` segment below `evals/files/` (any depth, any letter case): every case file reaches both arms, and `.claude/` is where Claude Code finds skills, so such a file could hand the no-skill arm a skill without `verdictOf` calling the turn invalid. `.mcp.json` is left alone, since the arms run with `--strict-mcp-config`. It is copied, a directory whole, into both arms' directories at its path below `evals/files/`. No case needs it today: every case that read as if a project were on disk was answerable once its prompt said so, which the card prefers. **Prompts that state their context (scope item 2).** Thirty prompts that named a project file to create or fix, or referred to "our app" state the model would go looking for, now end with one sentence saying none of the project's files are in the directory and what the answer should carry (the file, the change, the commands). Two needed facts as well: `objectstack-api/endpoints-auth-routes#2` named "the lead feed" defined only by case #1, and now describes it; `#6` asked to "fix the import body" without giving it, and now gives it. `objectstack-ai/skills-tools-knowledge#5`, whose right answer refuses the requested file, says "answer from what is stated here" so the sentence does not push toward writing that file. Changed: `objectstack-ai/skills-tools-knowledge#1 #4 #5`, `objectstack-api/endpoints-auth-routes#1 #2 #6`, `objectstack-automation/flows-triggers-approvals#5`, `objectstack-data/objects-fields-relationships#1 #9`, `objectstack-i18n/bundles-locales-coverage#2 #4`, `objectstack-platform/config-plugins-ops#1 #3 #5 #7 #8 #17 #21`, `objectstack-ui/views-apps-actions-pages#1 #2 #4`, `objectstack-ui/record-page#3`, `objectstack-upgrade/protocol-major-upgrade#1 #2 #3`, `objectui/page-builder#2 #3 #4`, `objectui/project-setup#3`, `objectui/data-integration#3`. **Assertion review (scope item 1).** Every case's assertions in all 12 bundles were read once, with each `must_contain` token checked mechanically against the bundle's non-eval text and the prompt. A token was changed only when one of these was demonstrated: it is absent from both the skill and the prompt and is one spelling of the answer; the prompt itself spells the answer another way; it names a value the author is free to choose; it is a whole compound expression whose formatting is free; or, for a forbidden token, the prompt or the skill carries it verbatim, so a right answer that names what is wrong quotes it. Eleven cases changed: | case | was | now | why | |:--|:--|:--|:--| | `objectstack-automation/flows-triggers-approvals#13` | must `hotcrm.custom` | must `.custom` | absent from the automation skill, which says "the base's paired `.custom` package"; any answer naming the pair carries `.custom` | | `objectstack-i18n/bundles-locales-coverage#10` | forbid `verdict: {` | forbid `verdict: { summary: '` | a right answer quotes the nested shape as the wrong one; narrowed to the nested key authored with a string value | | `objectstack-data/hooks-security-seeds-datasources#14` | forbid `****` | forbid `'138****` | the prompt and the skill (`references/seeds.md`: no `138****4207`) both carry the masked form, so a right answer naming what is refused quotes it; narrowed to the masked value as an authored string | | `objectstack-data/objects-fields-relationships#10` | forbid `required: true` | forbid `required: true,` and `required: true }` | the prompt asks for `required`; a right answer declines it by name; narrowed to the key as authored inside an object | | `objectstack-data/objects-fields-relationships#12` | must `filter: { status: 'completed' }` | must `filter:` | the prompt names neither the status field nor its stored value; the forbidden Chinese-value tokens still carry the case | | `objectstack-data/objects-fields-relationships#14` | must `value: 'active'` | must `value: '` | the stored value for 合作中 is the author's choice; the forbidden `value: '合作中'` still carries the case | | `objectstack-ui/views-apps-actions-pages#16` | must the whole `read: { url: '…' }` object; must `seed: [{ param: 'plan_token', path: 'token' }]` | must the URL `/api/v1/packages/${ctx.recordId}/upgrade-plan?version=${param.version}`; must `seed:` and `path: 'token'` | a whole object as one string binds the formatting; `plan_token` is the author's name for the param | | `objectstack-ai/skills-tools-knowledge#5` | forbid `defineAgent(` | forbid `defineAgent({` | the prompt asks for that call and a right answer refuses it by name (`defineAgent()`); narrowed to the authored call | | `objectstack-ai/skills-tools-knowledge#6` | must `pendingActions.list` | dropped | absent from the AI skill, which names the list door `GET /api/v1/ai/pending-actions`; the refusal tokens carry the case | | `objectui/testing#2` | must `React Testing Library` | must `@testing-library/react` | the prompt says "RTL"; a right answer can be all code, and every RTL test imports this module | | `objectstack-upgrade/protocol-major-upgrade#3` | must `never executed`; forbid `type: 'javascript'` | dropped; forbid `transform: { type: 'javascript'` | the skill says "never ran" and "unexecuted"; the prompt carries the forbidden token verbatim (as ``transform` = { type: 'javascript' …``), narrowed to the re-authored transform | ## Tests - `packages/qa/scenarios/test/skill-evals/skill-evals.test.ts`: two new `describe` blocks, 11 tests. They cover the reader (trigger kind, refusals, the one-kind bundle refusal, `files` paths), the judge (loaded by Skill launch or by read; a same-prefix bundle or another skill is not a load; loaded turns judged on any ending; an unloaded cut-short turn is `error`; the no-skill arm is `invalid`), hash stability for an unchanged behaviour case, a round planning trigger cases on one arm and the summary tallying them apart, `--regrade` keeping trigger cases planned, `files` placed on both arms, and `files` entries under `.claude/` refused (`.claude-notes.md`, `claude/` and `.mcp.json` still read). - `--self-test`: 9 new rows (roster 21 → 30, floor pinned at 30), run against the real catalog from the CLI. - Ablation, one behaviour (trigger grading by a read), on the committed tree: deleting the read-evidence line in `loadEvidence` via `scripts/ablation-replace.mjs` turned 4 tests red (two trigger tests, and the two `--self-test can fail` tests through the self-test's own trigger row); restored, `git diff HEAD` empty, blob equal to HEAD. The suite imports `src/` directly, so no rebuild was involved. - Ablation, round 2 (the `.claude` refusal), on the committed tree: replacing the refusal's condition with `if (false) {` via `scripts/ablation-replace.mjs` (anchor 1 → 0, blob `e5f089ae1d12` → `2e9983a9bf81`) turned 3 tests red: the new reader test, and the two `--self-test can fail` tests through the self-test's new row. Restored: blob equal to HEAD, `git diff HEAD` empty. ## Acceptance notes - **The model round ran separately, after this PR opened.** `claude-haiku-5-5`, effort medium, on `8d82dcb937`: 476 of 476 turns. Trigger cases: 30 of 30 loaded when they should; 8 of 12 left alone, and all 4 false loads were by reading the skill's files only. Behaviour cases: with-skill 130 of 215, no-skill 9 of 217. Trigger baseline ("before") for #34769: [comment 6964639551](#34789 (comment)). Judging #34769 against that baseline is still owed, so this PR stays Part of #34789. With 1 repetition each negative trigger case is a single turn, so one flip moves a skill's left-alone rate by 50 points; comparisons for #34769 should run with `--repeats 3`. Round 2's `.claude` refusal changes no case in the catalog (none uses `files`), so the round's records still regrade as they are. - **Reviewed and left as they are**, because no literal token separates the wrong claim from a right answer's negation of it. The grader is a literal substring match by design, and changing behaviour grading is outside this card's file surface: - `objectstack-data/hooks-security-seeds-datasources#15` forbids `会自动预填`, contained in 不会自动预填; - `objectstack-ask/metric-selection-fallback#6` forbids `不存在`; - `objectstack-ui/views-apps-actions-pages#13` forbids `ready to use`; - `objectstack-api/endpoints-auth-routes#5` forbids `'search'` and `'restore'`; - `objectui/app-composition#3` forbids `"path": "/projects"` and `objectui/protocol#3` forbids `"cols":`, both present verbatim in the prompt with no authored-only form; - `objectstack-ai/skills-tools-knowledge#5` forbids `knowledge:`, verbatim in the prompt; - `objectstack-ai/skills-tools-knowledge#7` requires `do not retry`, the skill's own words (a contraction would miss). - **Quote style.** Every token in the catalog is spelled with single quotes, as the skills and this codebase write code; an answer in double quotes misses all of them. Not changed: it is the catalog's convention, not one case's spelling. - **Reach, not spelling, carried by #34789.** `objectstack-api/endpoints-auth-routes#6` requires `sourceField` / `targetField`, which only the spec source teaches (`api/export.zod.ts`), and the turn's empty directory has no `node_modules`. `objectstack-automation/flows-triggers-approvals#16` requires `notices.`, which lives in `objectstack-data`'s `rules/lifecycle.md`, while the arm installs only the automation bundle. Both fail for a reason other than spelling or a missing project; a round will show whether they need the eval seat's attention. - **Trigger-arm design limit.** The with-skill arm installs the case's bundle alone, so a negative case asks whether this skill stays out with no competitor present, not which of several skills the model picks. That is the narrower question, and the one #34769's "Not for" clause changes. - Clause-② measured from the diff: `src/skill-evals/` is in no tsup entry and no export or bin. After `pnpm --filter @objectstack/scenarios build`, `should_trigger`, `placeCaseFiles` and `skillFilesRead` hit 0 files under `dist/`, while the control `subscriptionOnlyEnv` hits `dist/cli.js` and `dist/runner.js`. What ships is the README text, hence the `patch` changeset. - #34949, the serial constraint, merged during this work; this branch merged `origin/main` and calls `prepareArmWorkdir` with its new three-argument form. ## Verification Head `c169dc85d5` (round 2: the gates, the suite and the CLI runs below ran on it; round 1 ran them on `8d82dcb937`). <details><summary>scenarios package: typecheck and tests</summary> - `pnpm --filter '@objectstack/scenarios^...' build`, then `pnpm --filter @objectstack/scenarios typecheck`: exit 0. - `pnpm --filter @objectstack/scenarios build`, then `pnpm --filter @objectstack/scenarios test` (round 2, under the lock): 39 of 39 files, 1096 of 1096 tests passed. - `vitest run test/skill-evals/skill-evals.test.ts`: 35 of 35 passed on `8d82dcb937`; 36 of 36 on `c169dc85d5` (round 2), with `pnpm --filter @objectstack/scenarios typecheck` exit 0. </details> <details><summary>model-free CLI runs on the real catalog</summary> - `pnpm --filter @objectstack/scenarios skill-evals --self-test`: `✓ skill-evals self-test: 30 rows pass.` exit 0 (round 2). - Trigger baseline from the model round: [comment 6964639551](#34789 (comment)) (haiku-5-5, medium, `8d82dcb937`, 476/476 turns). One repetition: each negative is a single turn, so compare with `--repeats 3`. - `pnpm --filter @objectstack/scenarios skill-evals --dry-run`: exit 0, the catalog loads with no refusal; `217 behaviour case(s) × 2 arms + 42 trigger case(s) × the with-skill arm, × 1 = 476 turn(s)`; `trigger cases: 30 should load the bundle, 12 should not`. </details> <details><summary>derived gate families (dispatch-gates --commands, 76 families)</summary> `dispatch-gates --ran`: `76 derived famil(ies) accounted for — 75 run, 1 NOT-MEASURED`. - NOT MEASURED: `pnpm check:dual-build-cjs-loads`, exit 3, PREREQUISITE NOT MET (reads every package's `dist/`; this box built only the scenarios closure). CI runs it. - First run exit 3 (prerequisite), re-run exit 0: `pnpm --filter @objectstack/spec run check:skill-examples` (after building `@objectstack/client-react`: 347 prose examples type-check). `pnpm check:type-check-debt` exited 0 on the first run this round. - `pnpm --dir ui exec vitest run scripts/`: 171 files passed, 2 skipped; 5077 tests passed. - `node scripts/check-adr-0087-registration.mjs --base origin/main` · exit 0 - `node scripts/check-adr-0087-registration.mjs --self-test` · exit 0 - `node scripts/check-changeset-no-major.mjs --base origin/main` · exit 0 - `node scripts/check-closing-keyword-parity.mjs` · exit 0 - `node scripts/check-closing-keyword-parity.mjs --self-test` · exit 0 - `node scripts/check-comment-mask-adoption.mjs` · exit 0 - `node scripts/check-comment-mask-adoption.mjs --self-test` · exit 0 - `node scripts/check-comment-mask-corpus.mjs` · exit 0 - `node scripts/check-doc-route-spelling.mjs --advisory` · exit 0 - `node scripts/check-doc-route-spelling.mjs --self-test` · exit 0 - `node scripts/check-dts-emitted.mjs --self-test` · exit 0 - `node scripts/check-empty-changeset.mjs --base origin/main` · exit 0 - `node scripts/check-empty-changeset.mjs --self-test` · exit 0 - `node scripts/check-issue-citations.mjs` · exit 0 - `node scripts/check-plugin-teardown-shape.mjs` · exit 0 - `node scripts/check-plugin-teardown-shape.mjs --self-test` · exit 0 - `node scripts/ci/assert-turbo-remote-cache.mjs --self-test` · exit 0 - `node scripts/ci/plan-test-core-shards.mjs --self-test` · exit 0 - `node scripts/ci/prune-turbo-cache.mjs --self-test` · exit 0 - `node scripts/ci/snapshot-next.mjs --self-test` · exit 0 - `node scripts/docs-audit/check-affected-docs.mjs` · exit 0 - `node scripts/docs-audit/check-drift-comment.mjs` · exit 0 - `node scripts/pm/check-governed-queue-guard.mjs --self-test` · exit 0 - `node scripts/pm/release-rehearsal-clone.mjs --self-test` · exit 0 - `node scripts/release-pending-publish.mjs --self-test` · exit 0 - `pnpm --filter @objectstack/lint run check:doc-formula-expressions` · exit 0 - `pnpm --filter @objectstack/spec run check:duration-unit-keys` · exit 0 - `pnpm check:adr-anchors` · exit 0 - `pnpm check:agent-test-spelling` · exit 0 - `pnpm check:changeset-gate-self-tests` · exit 0 - `pnpm check:ci-filter-parity` · exit 0 - `pnpm check:closed-ceremony-text` · exit 0 - `pnpm check:corpus-claim-drift` · exit 0 - `pnpm check:cross-package-test-inputs` · exit 0 - `pnpm check:doc-authoring` · exit 0 - `pnpm check:driver-memory-census` · exit 0 - `pnpm check:dts-closure` · exit 0 - `pnpm check:engine-double-contract` · exit 0 - `pnpm check:gitlink-declared` · exit 0 - `pnpm check:issue-citations` · exit 0 - `pnpm check:keyed-text-bounds` · exit 0 - `pnpm check:lean-entry-closure` · exit 0 - `pnpm check:logger-receiver-detach` · exit 0 - `pnpm check:nul-bytes` · exit 0 - `pnpm check:objectql-double-limit` · exit 0 - `pnpm check:optional-error-sink` · exit 0 - `pnpm check:org-identifier` · exit 0 - `pnpm check:page-declaration-shape` · exit 0 - `pnpm check:platform-object-tenancy-census` · exit 0 - `pnpm check:pm-governed-merges` · exit 0 - `pnpm check:pm-skill-id-lint` · exit 0 - `pnpm check:published-files` · exit 0 - `pnpm check:query-options-erasure` · exit 0 - `pnpm check:refd-timer-probe` · exit 0 - `pnpm check:registry-log-declared` · exit 0 - `pnpm check:rest-log-spy-declared` · exit 0 - `pnpm check:role-word` · exit 0 - `pnpm check:settings-bind-window` · exit 0 - `pnpm check:skill-compatibility` · exit 0 - `pnpm check:skill-frame-sync` · exit 0 - `pnpm check:skill-identifier-liveness` · exit 0 - `pnpm check:skill-links` · exit 0 - `pnpm check:slot-lookup` · exit 0 - `pnpm check:sourcemap-no-sources-content` · exit 0 - `pnpm check:system-context-census` · exit 0 - `pnpm check:test-source-alias` · exit 0 - `pnpm check:tier-file-adoption` · exit 0 - `pnpm check:type-check-coverage` · exit 0 - `pnpm check:undeclared-dep-imports` · exit 0 - `pnpm check:vouch-for-reference-callers` · exit 0 - `pnpm check:watch-hint-literal` · exit 0 - `pnpm check:where-matcher` · exit 0 </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzfr1xZSFZzCR8HnqXX --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 32fe321 commit 62da8a3

31 files changed

Lines changed: 970 additions & 85 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/scenarios': patch
3+
'@objectstack/skills': patch
4+
---
5+
6+
docs(skills): trigger cases for the six metadata skills, and eval cases that grade the skill instead of a spelling or a missing project
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
`@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.
12+
13+
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.

‎packages/qa/scenarios/README.md‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,8 @@ wrapper, with no change to the runner.
755755

756756
Every published skill bundle carries eval cases (`skills/BUNDLE/evals/*.json`: a `prompt`, an `expected_output` and
757757
`assertions.must_contain` / `must_not_contain`). `skill-evals` sends each case to the local Claude Code login twice,
758-
once with the bundle installed and once without, and grades each answer by the case's own tokens. It runs from this
759-
checkout only. It is not part of the published `bin` or `exports`, not a CI job and not a merge gate. The cases are
758+
once with the bundle installed and once without, and grades each answer by the case's own tokens. A trigger case
759+
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
760760
the skill authors' and the runner never edits them.
761761

762762
```bash
@@ -789,14 +789,26 @@ pnpm --filter @objectstack/scenarios skill-evals --self-test # the runner's o
789789
record's `armEvidence` says whether the turn launched the bundle (`launched`) or nothing in the stream shows it
790790
(`not-shown`). A turn with no answer is `error`: the process failed or timed out, or the result line is not
791791
`success` (`error_max_turns` included). Both kinds are counted and named, and neither is in a denominator.
792+
- **Trigger cases**: an entry with `"should_trigger": true | false` in place of `assertions` (the reader refuses one
793+
carrying both) asks whether the skill was loaded when it should be and left alone when it should not. It runs on
794+
the with-skill arm only and is graded on the turn, never on its answer: the turn loaded the bundle when it launched
795+
it with the `Skill` tool or read a file under its `.claude/skills/BUNDLE/` (the record's `trigger.loadedBy` says
796+
which), and the case passes when that matches `should_trigger`. A turn that loaded the bundle is judged however it
797+
ended; one that did not is judged only when it ended `success`, and is `error` otherwise. A bundle whose trigger
798+
cases are all positive, or all negative, is refused. The summary reports trigger cases in their own section beside
799+
the behaviour cases, never inside their pass rates: per bundle, loaded when it should, left alone when it should
800+
not, the missed loads and the false loads.
801+
- **Case files**: a case's `files` entries are paths under the bundle's `evals/files/` (anything else is refused, and
802+
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
803+
`evals/files/`, so the arms still differ only in the bundle. A case whose prompt states its context needs none.
792804
`--regrade DIR` applies the current rules to a recorded round's answers and arm facts. A changed record keeps the
793805
verdict its turn was first given as `regradedFrom`. Each record carries `caseHash`, a hash of its case's prompt and
794806
token lists as the turn ran them. A case changed or removed since the round is set apart: it is not regraded, its
795807
records are left as they are, and the summary names it outside every pass rate. A record with no hash predates the
796808
hash; it is regraded against the case as it is now, and the summary counts it as unhashed.
797809
- **Records**: by default the round goes to `docs/qa/platform-checklist/runs/skill-evals/ROUND/` (git-ignored), or to
798810
`--out`. It holds one `runs/*.json` per turn (verdict, missing and forbidden tokens, the answer, the skills listed
799-
and launched, the served model, the CLI's notional cost and the rate-limit reading), `round.json` (environment,
811+
and launched, the skill files read, the served model, the CLI's notional cost and the rate-limit reading), `round.json` (environment,
800812
scope and the full per-case scores on both arms) and `summary.md`. The summary has one row per bundle (each arm's
801813
pass rate, the with-skill failing cases, and the cases where the no-skill arm scored at least as high) and then
802814
every case. `summary.github.md` is the same text with angle brackets spelled `(lt)` / `(gt)` for a GitHub body.

‎packages/qa/scenarios/src/skill-evals/arms.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,16 @@ export function prepareArmWorkdir(arm: Arm, bundle: string, skillsRoot: string):
101101
}
102102
return { cwd, mcpConfigPath, root };
103103
}
104+
105+
/**
106+
* Place a case's `files` in a turn's project: each entry, a path under the
107+
* bundle's `evals/files/` (the reader has refused any other), is copied to the
108+
* same path below `evals/files/` inside `cwd`, a directory whole. Called for
109+
* both arms alike, so the arms still differ only in the bundle.
110+
*/
111+
export function placeCaseFiles(files: readonly string[] | undefined, bundle: string, skillsRoot: string, cwd: string): void {
112+
for (const f of files ?? []) {
113+
const below = f.split('/').slice(2).join('/');
114+
cpSync(join(skillsRoot, bundle, f), join(cwd, below), { recursive: true, dereference: true });
115+
}
116+
}

‎packages/qa/scenarios/src/skill-evals/cases.ts‎

Lines changed: 109 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,27 @@
99
* { "skill_name": BUNDLE, "evals": [ { "id", "prompt", "expected_output",
1010
* "files": [], "assertions": { "must_contain": [..], "must_not_contain": [..] } } ] }
1111
*
12+
* A TRIGGER case asks the other question about a skill: was it loaded when
13+
* it should be, and left alone when it should not. It is the same entry with
14+
* `"should_trigger": true | false` in place of `assertions`, and it is graded
15+
* on whether the with-skill turn loaded the bundle, never on its answer:
16+
*
17+
* { "id", "prompt", "should_trigger": false, "files": [] }
18+
*
19+
* `files` names what a case needs on disk: each entry is a path under the
20+
* bundle's `evals/files/` (`"evals/files/src/objects/task.object.ts"`), a file
21+
* or a directory, placed in the turn's working directory at the path below
22+
* `evals/files/` on both arms. `evals/` itself is never copied into a turn, so
23+
* a case's files reach it only this way.
24+
*
1225
* The reader is strict, never lenient: a file that does not parse, a case
1326
* whose prompt is not a string, an assertion list that is not a list of
14-
* strings, or a case with no assertion at all is a located refusal — never a
15-
* case graded as a pass because nothing was asked of it. The cases themselves
16-
* are not this runner's to edit.
27+
* strings, a case with no assertion at all, a trigger case that also carries
28+
* assertions, a `files` entry outside `evals/files/` or missing from it, and a
29+
* bundle whose trigger cases are all of one kind (all positive cannot show a
30+
* false load; all negative cannot show a missed one) are located refusals —
31+
* never a case graded as a pass because nothing was asked of it. The cases
32+
* themselves are not this runner's to edit.
1733
*/
1834

1935
import { createHash } from 'node:crypto';
@@ -34,6 +50,14 @@ export interface SkillEvalCase {
3450
expectedOutput?: string;
3551
mustContain: string[];
3652
mustNotContain: string[];
53+
/**
54+
* Set ⇒ a trigger case: graded on whether the with-skill turn loaded the
55+
* bundle (`true`: it should; `false`: it should not), on that arm only. Its
56+
* token lists are empty.
57+
*/
58+
shouldTrigger?: boolean;
59+
/** Paths under the bundle's `evals/files/` placed in the turn's project; absent ⇒ none. */
60+
files?: string[];
3761
}
3862

3963
/** A file or case the reader refused, with where. */
@@ -66,11 +90,40 @@ export const caseKey = (bundle: string, file: string, id: number | string): stri
6690
/**
6791
* The case as a turn meets it: a hash of the prompt the turn is asked and the
6892
* two token lists its answer is graded on (`expected_output` is neither sent
69-
* nor graded, so it is left out). Every run record carries it, so `--regrade`
70-
* can tell a case reworded since the round from the case that ran. Pure.
93+
* nor graded, so it is left out), and, only when the case has them, its
94+
* trigger kind and its `files` list (names, not contents) — so a behaviour
95+
* case with no files hashes as it did before either existed. Every run record
96+
* carries it, so `--regrade` can tell a case reworded since the round from the
97+
* case that ran. Pure.
7198
*/
72-
export const hashCase = (c: Pick<SkillEvalCase, 'prompt' | 'mustContain' | 'mustNotContain'>): string =>
73-
`sha256:${createHash('sha256').update(JSON.stringify([c.prompt, c.mustContain, c.mustNotContain])).digest('hex')}`;
99+
export const hashCase = (c: Pick<SkillEvalCase, 'prompt' | 'mustContain' | 'mustNotContain' | 'shouldTrigger' | 'files'>): string => {
100+
const extra = {
101+
...(c.shouldTrigger !== undefined ? { shouldTrigger: c.shouldTrigger } : {}),
102+
...(c.files?.length ? { files: c.files } : {}),
103+
};
104+
const parts: unknown[] = [c.prompt, c.mustContain, c.mustNotContain];
105+
if (Object.keys(extra).length) parts.push(extra);
106+
return `sha256:${createHash('sha256').update(JSON.stringify(parts)).digest('hex')}`;
107+
};
108+
109+
/** The directory under a bundle that holds the files cases place in a turn's project. */
110+
export const CASE_FILES_DIR = 'evals/files';
111+
112+
/** Why a `files` entry is refused; `undefined` ⇒ it names a path under `evals/files/` that lands outside any `.claude/`. Pure. */
113+
export function caseFileProblem(entry: string): string | undefined {
114+
const parts = entry.split('/');
115+
if (entry.includes('\\') || parts.length < 3 || `${parts[0]}/${parts[1]}` !== CASE_FILES_DIR || parts.slice(2).some((p) => p === '' || p === '.' || p === '..')) {
116+
return `\`files\` entry \`${entry}\` is not a path under \`${CASE_FILES_DIR}/\` (forward slashes, no \`.\` or \`..\` segment)`;
117+
}
118+
// Both arms receive every case file, and `.claude/` is where Claude Code finds
119+
// skills: a case file there would hand the no-skill arm a skill without
120+
// `verdictOf` ever calling the turn invalid. Any depth, any letter case (a
121+
// case-insensitive disk resolves `.Claude` to the same directory).
122+
if (parts.slice(2).some((p) => p.toLowerCase() === '.claude')) {
123+
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`;
124+
}
125+
return undefined;
126+
}
74127

75128
/** Read one eval file's text into cases, or refusals. Pure over its inputs. */
76129
export function parseEvalFile(bundle: string, file: string, text: string): { cases: SkillEvalCase[]; refusals: SkillEvalRefusal[] } {
@@ -102,19 +155,45 @@ export function parseEvalFile(bundle: string, file: string, text: string): { cas
102155
refusals.push({ path: at, message: '`prompt` is not a non-empty string' });
103156
return;
104157
}
105-
const a = e.assertions;
106-
if (typeof a !== 'object' || a === null || Array.isArray(a)) {
107-
refusals.push({ path: at, message: '`assertions` is not an object' });
158+
const files = e.files ?? [];
159+
if (!isStringList(files)) {
160+
refusals.push({ path: at, message: '`files` must be a list of strings' });
108161
return;
109162
}
110-
const { must_contain: mc = [], must_not_contain: mnc = [] } = a as Record<string, unknown>;
111-
if (!isStringList(mc) || !isStringList(mnc)) {
112-
refusals.push({ path: at, message: '`assertions.must_contain` / `must_not_contain` must each be a list of strings' });
163+
const badFile = files.map(caseFileProblem).find((m) => m !== undefined);
164+
if (badFile) {
165+
refusals.push({ path: at, message: badFile });
113166
return;
114167
}
115-
if (mc.length + mnc.length === 0) {
116-
refusals.push({ path: at, message: 'asserts nothing: a case with no `must_contain` and no `must_not_contain` would pass every answer' });
117-
return;
168+
let mc: string[] = [];
169+
let mnc: string[] = [];
170+
const trigger = e.should_trigger;
171+
if (trigger !== undefined) {
172+
if (typeof trigger !== 'boolean') {
173+
refusals.push({ path: at, message: '`should_trigger` is neither `true` nor `false`' });
174+
return;
175+
}
176+
if (e.assertions !== undefined) {
177+
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' });
178+
return;
179+
}
180+
} else {
181+
const a = e.assertions;
182+
if (typeof a !== 'object' || a === null || Array.isArray(a)) {
183+
refusals.push({ path: at, message: '`assertions` is not an object' });
184+
return;
185+
}
186+
const { must_contain: rawMc = [], must_not_contain: rawMnc = [] } = a as Record<string, unknown>;
187+
if (!isStringList(rawMc) || !isStringList(rawMnc)) {
188+
refusals.push({ path: at, message: '`assertions.must_contain` / `must_not_contain` must each be a list of strings' });
189+
return;
190+
}
191+
if (rawMc.length + rawMnc.length === 0) {
192+
refusals.push({ path: at, message: 'asserts nothing: a case with no `must_contain` and no `must_not_contain` would pass every answer' });
193+
return;
194+
}
195+
mc = rawMc;
196+
mnc = rawMnc;
118197
}
119198
const key = caseKey(bundle, file, id);
120199
if (seen.has(key)) {
@@ -131,6 +210,8 @@ export function parseEvalFile(bundle: string, file: string, text: string): { cas
131210
...(typeof e.expected_output === 'string' ? { expectedOutput: e.expected_output } : {}),
132211
mustContain: mc,
133212
mustNotContain: mnc,
213+
...(typeof trigger === 'boolean' ? { shouldTrigger: trigger } : {}),
214+
...(files.length ? { files } : {}),
134215
});
135216
});
136217
return { cases, refusals };
@@ -154,11 +235,22 @@ export function loadSkillEvalCatalog(root: string): SkillEvalCatalog {
154235
.filter((d) => d.isFile() && d.name.endsWith('.json'))
155236
.map((d) => d.name)
156237
.sort();
238+
const mine: SkillEvalCase[] = [];
157239
for (const file of files) {
158240
const r = parseEvalFile(bundle, file, readFileSync(join(dir, file), 'utf8'));
159-
cases.push(...r.cases);
241+
for (const c of r.cases) {
242+
const missingFile = (c.files ?? []).find((f) => !existsSync(join(root, bundle, f)));
243+
if (missingFile) refusals.push({ path: `${bundle}/evals/${file}: ${c.key}`, message: `\`files\` names \`${missingFile}\`, which is not in the bundle` });
244+
else mine.push(c);
245+
}
160246
refusals.push(...r.refusals);
161247
}
248+
const kinds = new Set(mine.filter((c) => c.shouldTrigger !== undefined).map((c) => c.shouldTrigger));
249+
if (kinds.size === 1) {
250+
const only = kinds.has(true) ? 'positive' : 'negative';
251+
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'}` });
252+
}
253+
cases.push(...mine);
162254
}
163255
const unlistedBundles = bundles.filter((b) => notUserInvocable(readFileSync(join(root, b, 'SKILL.md'), 'utf8')));
164256
return { root, bundles, unlistedBundles, cases, refusals };

0 commit comments

Comments
 (0)