Repository navigation
Commit 02a1e2f
feat(scenarios): door mode builds a card through the MCP draft door with no project, in skill and rule arms (#35241)
Part of #34780
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:场景卡评测运行器新增 `--modes door`:客户端只拿到应用的 MCP
草稿门和技能,没有任何项目文件;运行器替人建包、连客户端、发布草稿,然后按现有规则评分。
- 为什么改:要实测"托管的规则文本还需要多少",就得能在同一张卡上对比带不带某个技能、带不带某组规则时的构建结果。
- 风险与回滚:只改 `@objectstack/scenarios`(评测工具包),产品包零改动;不传 `--modes door`
时行为不变。回滚即还原本 PR。
- 先看:`packages/qa/scenarios/src/runner/orchestrate.ts` 的
`doorMode`(建包、取令牌、发布、评分顺序);`src/runner/door.ts` 的
`readDoorRules`(规则文件拒收条件);`src/runner/driver.ts` 的 `doorAuthor`(客户端只能调
`mcp__app`)。
- 两分钟验证:`pnpm --filter @objectstack/scenarios exec vitest run
--maxWorkers=2 test/runner/door.test.ts`,预期 21 个用例全绿。
- 需要你做的:合并后按 README「One round, five reps per arm」跑一轮(每个 arm 5
次),规则文件由你在仓库外提供。
## What changes
A fourth runner mode, `door`, in `@objectstack/scenarios`. No product
package is touched.
- **The client gets the draft door and nothing else.** A door turn runs
in a fresh, empty directory outside the host project, removed after the
turn. It is handed the booted app's MCP server with an OAuth token
scoped `openid metadata:write`; the token sits in a 0600 config file
outside that directory and never appears on argv or in the record. It
may call `mcp__app` (plus `Skill` when given skills); `Bash`, `Edit`,
`Write` and `NotebookEdit` are denied. The prompt (`doorBuildPrompt`)
names the package and namespace and is the same text in every arm.
- **Person-equivalent steps around the turn** (`doorMode`,
`src/runner/orchestrate.ts`). Before the turn, the runner boots the host
with the OAuth provider on and creates a writable package
`com.scenario.NAMESPACE` in the card's namespace (`POST
/api/v1/packages`). It mints the token over OAuth 2.1 + PKCE
(`mintAuthoringToken`, `src/runner/app.ts`). After the turn, it lists
the drafts and publishes them (`POST
/api/v1/packages/ID/publish-drafts`). Then it grades what the
environment serves, exactly as a scratch build is graded: Build half,
then Run half. A publish that does not answer `published` is a finding
naming each refused draft; the door answers a refusal on a 200, with
`outcome: refused` under `data`. A refused package or token is a
finding, and a harness without the doors is a skip naming them.
- **Arms** (`src/runner/door.ts`, `src/runner/cli.ts`). There are two:
- **Skills.** `--door-skills DIR`, less `--door-skill-omit`, uses the
`--ask-skills` reader and its closed front-matter set.
- **Rules.** `--door-rules FILE` or `OS_SCENARIOS_DOOR_RULES`, less
`--door-rules-omit`, takes rule texts **the maintainer supplies at run
time** in a documented generic format: `{ rules: [{ id, text }], sets?
}`. The texts reach the client as its directory's `CLAUDE.md`.
A missing, malformed or in-checkout rules file is refused before any
card runs, naming what is wrong. The record states the arm: skills with
sha256, the rules file's name and sha256, and the active and omitted
ids, never a text. `summary` refuses to sum two arms.
- **Replay.** `RecordedDriver` re-sends a door turn's recorded
`save_metadata_draft` / `delete_metadata_draft` calls through the
replay's own door and token, and reports a mismatch as not faithful.
Codex and external drivers are refused for door mode.
- README: a door mode section with the rules file format, the flags, and
the maintainer's one-round command at five reps per arm.
## Tests
The tests use replay and stub drivers only; no live model is run.
- `test/runner/door.test.ts` (new, 21 cases), with invented rule texts:
- **Rules file:** a valid file; each refusal (missing, a directory, no
JSON, unknown key, empty text, bad id, empty set, duplicate id, a set
naming an unknown id, a set named like a rule, an unknown selector, an
empty selector entry, a selector that omits every rule, a file inside
the checkout); `renderDoorRules`; `omitSkills`; `doorArmText`.
- **Live-driver door turn, via a stand-in `claude`:** `--allowedTools
mcp__app`; the four denied tools; an empty cwd; the token only in the
MCP config; the arm's skills under `.claude/skills/` less the omitted
one; the rules as `CLAUDE.md`; the record's arm; a scratch turn
untouched by the arm.
- **CLI parse and refusals:** door flags without door mode; an omit
without its source; Codex/external refused; replay refusing live flags.
- **Replay and summary:** a replay states the arm; `summary` refuses
mixing arms.
- `test/runner/orchestrate.test.ts` gains a top-level `runCard` describe
for door mode (6 cases, on the file's existing fake harness):
- end to end, covering the empty client cwd outside the host, the
package, the token scope, the drafts, the publish, the scored Build and
Run halves, the scorecard line, and the token absent from the record;
- a publish refused on a 200;
- a publish short of `published` with no refused draft;
- a refused token, after which the driver is never asked;
- the harness-gap skip;
- a replay re-sending the saves through a new token, and a replay
against an app that refuses a save, which leaves the build not measured.
- One existing pin updated: the unknown-mode refusal now lists `door`.
## Acceptance notes
- **Maintainer action after merge.** This is the card's "Done when": one
eval round at five reps per arm. The containers are keyless, so no live
model ran here. The command is in `packages/qa/scenarios/README.md`
under "One round, five reps per arm". In short, for each arm:
`pnpm --filter @objectstack/scenarios run-scenarios --modes door
[--door-skills "$PWD/skills" [--door-skill-omit NAME]] [--door-rules
/abs/path/outside/repo/rules.json [--door-rules-omit SET]] --record
runs/door-ARM/repN.rec.json --out runs/door-ARM/repN`
Then run `summary --mode door runs/door-ARM` once per arm.
- **NOT MEASURED live.** Nothing was run against a live `os dev`:
- the OAuth flow on `os dev -p PORT` (canonical origin and token
audience);
- package creation and the publish of door-made drafts.
These doors were read from source, not exercised. A step the app refuses
is recorded as a finding naming the step, never as a score.
- **Follow-ups, not in this PR:**
- The build skill the "with build skill" arm needs (#34778) does not
exist yet. Until it does, the skills arm is the published `skills/`
directory with and without a named omission.
- The scenario-eval skill (governed `.claude/**`) needs a line about
door mode.
- The gallery exporter's record mode enum does not list `door`; door
records are not exported to the gallery yet.
- Moving a hosted rule corpus into this repository is left for the
maintainer's own explicit word. This PR takes rules only from a
maintainer-supplied file outside the repository, and every fixture text
is invented.
- **Ablation** (one-off, not a kept test):
- **Run 1** removed the `publish.outcome !== 'published' ||` clause and
checked it against the refused-publish case. That run stayed green: the
refused case also carries `failed[]`, so it does not pin that clause.
- **The fix.** I added the `published_unregistered` case, which
publishes with no refused draft.
- **Run 2** applied the same deletion and that case went red (`expected
[] to deeply equal [ Array(1) ]`). The restore was proven: blob == HEAD
and `git diff HEAD` was empty.
- **A first no-op attempt.** An empty `--replacement` was refused by
`ablation-replace` before anything ran, so it is not counted.
## Verification
All at head `4e1b7624f1e`.
<details><summary>Package tests and typecheck (under
os-verify-lock)</summary>
- `pnpm --filter @objectstack/scenarios build && pnpm --filter
@objectstack/scenarios test`: `Test Files 40 passed (40)`, `Tests 1176
passed (1176)`, `VERDICT command-exit 0`.
- `pnpm --filter @objectstack/scenarios typecheck` (tsconfig includes
`test/**`): `VERDICT command-exit 0`.
- The dependency closure was built first: `pnpm
--workspace-concurrency=2 --filter '@objectstack/scenarios^...' build`,
`VERDICT command-exit 0`.
- `test:repo` was not run locally: the diff touches no repo-project
test. It is declared to CI.
</details>
<details><summary>Derived gate families</summary>
- `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack
--commands` derived 67 families against merge base `ec227fc7b`.
- All 67 ran at this head and exited 0. That includes
`check:error-code-casing`, which was red once on a lowercase test
fixture code and is fixed; `check:nul-bytes`; `check:published-files`;
`check:dts-closure`; `check:dual-build-cjs-loads`; and
`check:lean-entry-closure`.
- `--ran` reconciliation: `67 derived famil(ies) accounted for — 67 run,
0 NOT-MEASURED (a DERIVED zero — all 67 recorded an exit code and none
of them is 3)`.
- `node scripts/pm/overlap-check.mjs` before each push: `VERDICT clean
exit 0`.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbaX2qDxUq9sF93EqqL)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent f2078e3 commit 02a1e2f
17 files changed
Lines changed: 1486 additions & 55 deletions
File tree
- .changeset
- packages/qa/scenarios
- src/runner
- drivers
- test/runner
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
| |||
263 | 264 | | |
264 | 265 | | |
265 | 266 | | |
266 | | - | |
| 267 | + | |
267 | 268 | | |
268 | 269 | | |
269 | 270 | | |
| |||
280 | 281 | | |
281 | 282 | | |
282 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
283 | 371 | | |
284 | 372 | | |
285 | 373 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
55 | 67 | | |
56 | 68 | | |
57 | 69 | | |
58 | 70 | | |
59 | 71 | | |
| 72 | + | |
| 73 | + | |
60 | 74 | | |
61 | 75 | | |
62 | 76 | | |
| |||
179 | 193 | | |
180 | 194 | | |
181 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
182 | 210 | | |
183 | 211 | | |
184 | 212 | | |
| |||
365 | 393 | | |
366 | 394 | | |
367 | 395 | | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
368 | 416 | | |
369 | 417 | | |
370 | 418 | | |
| |||
377 | 425 | | |
378 | 426 | | |
379 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
0 commit comments