Repository navigation
feat(scenarios): run-scenarios --driver codex and --driver external:COMMAND, with the driver on each gallery app page - #31265
Conversation
…e driver on each gallery app page The scenario runner drives the OpenAI Codex CLI on a ChatGPT plan login and any command that speaks a stdin/stdout JSON driver contract, so the same card can measure another agent tool. The persona's API key reaches either only through a 0600 file. A replay names the driver of its recording, and each exported app page names the driver and its version. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mx64pxVGCbKfuxEwi
📓 Docs Drift CheckThis PR changes 1 package(s): 11 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 8 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin e159102d03db8ad8bd1d7a6962300000f1bece97 && git checkout e159102d03db8ad8bd1d7a6962300000f1bece97
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 455229e7aebae2fe91ada77736377fe145defba3 fb1d76f7d24678c01304f573d97d45a046409bf7 && git checkout -B drift-repro 455229e7aebae2fe91ada77736377fe145defba3 && git merge --no-ff fb1d76f7d24678c01304f573d97d45a046409bf7
node scripts/docs-audit/affected-docs.mjs --json 455229e7aebae2fe91ada77736377fe145defba3
|
|
domain:devx#3 · os-project-manager · session_01FEkQ5njkh3xbcDN6EtSfw7 Contract reviewServed-tier: Inputs: card #31159 (body, triage 6709176909, claim 6712196415, os-dev-report 6712807610), PR #31265 (body, 15-file list, net diff ① Derived judgments
② Semver levelChangeset ③ Boundary flagsFrom os-dev-report 6712807610 (
Check-runs on Implemented-by: VERDICT: PASS Generated by Claude Code |
|
domain:devx#3 · os-project-manager · session_01FEkQ5njkh3xbcDN6EtSfw7 席位核对Verdict: ACCEPT · head
Generated by Claude Code |
Requested by Leehom · project thread
Fixes #31159
Clause-②: yes
Metadata-protocol: none
维护者速读
--driver codex用本机 Codex CLI(codex exec --json)跑卡片,只认 ChatGPT 套餐登录;--driver external:命令让任何能按约定读写 JSON 的命令接进来(每次调用一个进程,stdin 进 JSON、stdout 出 JSON,约定写在包 README)。画廊每个应用页多一行- Driver:,写明驱动名和版本;回放记录写明原录制的驱动。packages/qa/scenarios,默认驱动claude的行为不变(只是把进程启动函数挪到drivers/process.ts共用)。最大的风险是人物 API key 泄露:key 只写进 0600 文件(外部命令拿到的是文件路径;Codex 是$CODEX_HOME下的临时 profile),用完即删,从不进 argv、环境变量或 stdin;端到端测试把整张 crm 卡经外部命令跑完,再在运行记录、录制、评分卡和画廊导出里逐文件搜 key。回滚即 revert 本 PR。packages/qa/scenarios/src/runner/drivers/external.ts(外部约定与 key 文件)、packages/qa/scenarios/src/runner/drivers/codex.ts(登录守卫、profile 文件、JSONL 解析)、packages/qa/scenarios/test/runner/external-driver.test.ts(端到端 key 搜索)。pnpm --filter '@objectstack/scenarios^...' build && pnpm --filter @objectstack/scenarios exec vitest run test/runner/external-driver.test.ts test/runner/codex-driver.test.ts,预期 2 个文件 20/20 通过。What changes
--driver external:COMMAND(src/runner/drivers/external.ts,ExternalDriver): theAgentDriverseam as a process contract,objectstack-scenario-driver/1.infoonce at start (the command names itself and its version: the record's driver isexternal:NAME, its version the one it gives; a command that cannot answer is refused before any card runs),author(step,prompt,cwd,tier,limits; runs incwd) andask(step,prompt,mcp: { url, configFile },limits; runs in the config file's directory).ExternalTurnSchema:replyText,toolCalls[{name, input, output, isError}], optionalmodelandnumTurns; an unknown key is refused). Exit 0 with that shape is the turn. A non-zero exit, a signal or the runner's timeout is a failed turnno-result(exit N); stdout that is not one JSON object of that shape isinvalid-output(…)withisError. A failed authoring turn leaves its Build half not measured (authorNotMeasured), a failed persona turn is graded on its empty reply. Never an empty pass.askwrites{"mcpServers":{"app":{"type":"http","url":…,"headers":{"Authorization":"Bearer KEY"}}}}(the Claude driver's--mcp-configshape) to a 0600 file in a fresh temp directory, passes its PATH inmcp.configFile, and deletes the directory when the call returns. The key is never on argv, in the environment or on stdin.limitscarriestimeoutMs(--author-timeoutforauthor, 5 min forask; the runner kills the call then) and, when given,maxTurnsandmodel. The command may ignore them; the record states them (DriverInfo,meta.process.maxTurns/requestedModel)../or../, and a first word holding/, resolves against the directory the runner starts in. The runner removesANTHROPIC_API_KEY,ANTHROPIC_AUTH_TOKEN,OPENAI_API_KEYandCODEX_API_KEYfrom the command's environment; it cannot see the command's login, soauthMethodreadsnot verified (an external command: …).--driver codex(src/runner/drivers/codex.ts,CodexDriver), built from the installed CLI (measurements below):OPENAI_API_KEYorCODEX_API_KEYis set, or whencodex login statussays anything butLogged in using ChatGPT(assertCodexSubscriptionLogin, pure, the counterpart ofassertSubscriptionLogin); every turn also passes-c forced_login_method="chatgpt", and both variables are removed from every child.codex exec --json --ephemeral --skip-git-repo-check -c forced_login_method="chatgpt" -c approval_policy="never" -p PROFILE -s … -C DIR [-m MODEL] -, the prompt on stdin. Authoring:-s workspace-write -c sandbox_workspace_write.network_access=truein the project (the Claude driver's Bash has the network too). Persona turns:-s read-onlyin an empty temp directory.$CODEX_HOME/scenario-runner-HEX16.config.toml, mode 0600, deleted infinally, holding[mcp_servers."app"]withurlandhttp_headers = { Authorization = "Bearer …" }, plusenabled = falsefor every server of the user's own config (codex mcp list --json, read once at start), the counterpart of--strict-mcp-config. argv carries the profile's NAME only. A user server already namedappis refused at start.parseCodexJsonlreads the events into the sameParsedTurn:agent_messagetexts joined intoreplyText;mcp_tool_call→ the app's own tool name (rawNamemcp__SERVER__TOOL), output the result's text (orstructured_content, or the error message),isErroronfailed;command_execution,file_change,web_searchkept as calls by their item type; a call started and never completed keepsoutput: undefined;turn.completed→success;turn.failed→turn.failed: MESSAGEwithisError; a top-levelerrorevent is a reconnect notice, not the end.--model,--author-model,--ask-model→-mper turn kind;--author-timeoutis the runner's own clock.codex exechas no turn cap, so--author-max-turnsand--ask-max-turnsare refused atmakeDriver(as the recorded driver refuses every live flag).DriverInfogainsreplayOf?: { driver, version? }, whichRecordedDriver.info()fills from the recording (a recording of a replay keeps the original). The gallery exporter writes- Driver: NAME VERSIONon every app page (driverText, exported from./export); a replay readsRECORDED-DRIVER VERSION (re-graded from a recording of that run), never the recording's path; an old replay record with noreplayOfsays it does not name its driver. The record schema readsenv.driver.version/replayOf(loose, both optional).runCliandnoResultmoved fromdriver.tstosrc/runner/drivers/process.ts(runTurnProcess, now taking the child environment), unchanged otherwise; the tool-result text reader moved there too (contentText) andtranscript.tsuses it.process.tsis not re-exported from./runner.makeDriver:codexandexternal:COMMAND(an empty command refused); the unknown-driver message listsclaude, codex, external:COMMAND, recorded:FILE.ApiBillingRefusedErrortakes an optional{ tool, login }(default Claude Code's, message unchanged).info/author/ask, the stdout shape, exit codes, timeout, limits, the key file), and the WorkBuddy finding. Changesetpatchwith both declaration lines.Public surface (Clause-②: yes, additive)
Nothing removed or renamed. Added to
@objectstack/scenarios/runner:CodexDriver,CodexDriverOptions,CODEX_API_BILLING_ENV,CODEX_TURN_CONFIG,CODEX_APP_SERVER,codexSubscriptionOnlyEnv,assertCodexSubscriptionLogin,codexProfileToml,parseCodexJsonl,ExternalDriver,ExternalDriverOptions,EXTERNAL_DRIVER_CONTRACT,EXTERNAL_STRIPPED_ENV,ExternalLimits,ExternalInfoInput,ExternalAuthorInput,ExternalAskInput,ExternalInfoSchema,ExternalToolCallSchema,ExternalTurnSchema,ExternalTurn,parseExternalCommand; the optional memberDriverInfo.replayOf; an optional second parameter onApiBillingRefusedError. Added to./export:driverText. CLI:--driver codex,--driver external:COMMAND.Ask 2: what was measured on the Codex CLI
Installed
@openai/codex@0.167.0(npm,codex-cli 0.167.0, linux-x64) into a scratch prefix in this container. No model turn ran: no login was used, and the container's proxy refuses OpenAI's hosts (HTTP CONNECT failed with status 403), so everyexecbelow stopped at the model call.Readings, each with its source
codex --help,codex exec --help(installed binary):exec"Run Codex non-interactively";[PROMPT]"If not provided as an argument (or if-is used), instructions are read from stdin";--json"Print events to stdout as JSONL";-m, --model;-s, --sandbox read-only|workspace-write|danger-full-access;-C, --cd;--skip-git-repo-check;--ephemeral"Run without persisting session files to disk";-p, --profile"Layer $CODEX_HOME/NAME.config.toml on top of the base user config";--ignore-user-config;-c key=value;--strict-config. No turn-cap flag;max_turnsand its spellings appear nowhere in the binary's strings.codex-rs/exec/src/exec_events.rsat tagrust-v0.167.0(raw.githubusercontent.com):thread.started {thread_id},turn.started,turn.completed {usage},turn.failed {error{message}},item.started|updated|completed {item{id,type,…}},error {message}; item typesagent_message {text},mcp_tool_call {server, tool, arguments, result{content, structured_content}, error{message}, status},command_execution {command, aggregated_output, exit_code, status},file_change,web_search,todo_list,reasoning,error. No event carries the served model. Seen live:thread.started,turn.started, thenerroreventsReconnecting... 2/5 (…)while the turn continued, so a top-levelerroris read as a notice. The docs the repository ships (docs/exec.md,docs/config.md,docs/authentication.mdat that tag) only point to developers.openai.com, which this container cannot reach (connect refused): the config reference was not read; every config key below was measured instead.$CODEX_HOME/scen.config.tomlwith[mcp_servers.app] url = "http://127.0.0.1:39123/mcp",http_headers = { Authorization = "Bearer FAKEKEY123" }:codex -p scen mcp list --jsonshows itstreamable_httpwith that header;codex exec --json -p scen …POSTedinitializeto a local listener withauthorization: Bearer FAKEKEY123(clientInfo.namecodex-mcp-client). A project.codex/config.tomlin the working directory was not read bymcp list(untrusted directory), so the driver does not use one.config.tomlserverother(port 39124) and the profile'sapp(39123), plainexec -p scencontacted both;--ignore-user-config -p scencontacted neither (it drops the profile too);[mcp_servers.other] enabled = falsein the profile →mcp listshows itenabled: false, andexeccontactedapponly. The key appeared in no file under$CODEX_HOMEbut the profile.codex login --with-api-key(a fake key) →codex login statusprints on stderrAPI key configured - sk-fake-***-0000, exit 0; an emptyCODEX_HOME→Not logged in, exit 1, also withCODEX_API_KEYorOPENAI_API_KEYset; the binary's strings holdLogged in using ChatGPT(and… using access token,… personal access token,… workload identity,… Amazon Bedrock …). With-c forced_login_method="chatgpt", the API-key login readsNot logged in, exit 1.exec --strict-config -c …:forced_login_method="chatgpt",approval_policy="never"andsandbox_workspace_write.network_access=trueare accepted;forced_login_method="bogus"→ "expectedchatgptorapi",approval_policy="bogus"→ "expected one ofuntrusted,on-failure,on-request,granular,never",sandbox_workspace_write.bogus_keyandbogus_top→ "unknown configuration field".codex execturn end to end (no ChatGPT login here, and live model runs are paused by the maintainer, cloud#3600), so aturn.completedstream was not seen live; its shape is the source's. The stand-in incodex-driver.test.tsreplays those shapes.Ask 3: WorkBuddy
Checked on 2026-11-07; no wiring, no UI bridge.
workbuddy: the one package calling itself a WorkBuddy command line,@workbuddy/cli-vnext@1.0.153(maintainerworkbuddy_developer,developer@workbuddy.com), read from its tarball without running it: a REST client for a WorkBuddy tenant API (commander; commandsauth,profiles,use,whoami; options--base-url,--client-id,--output json|table|raw), with no agent, no prompt mode and no MCP client. Its only URL ishttps://yourcompany.workbuddy.com; it is not Tencent's WorkBuddy.dsh-workbuddy-providerREADME (npm) describes reusing "WorkBuddy 桌面 App" credentials on macOS, and the app's model catalogue is fetched with "内置 CLI 版本号" (a built-in CLI version), but no published, documented headless mode with structured output and an MCP client was found.--driver external:(README), not runner code.Tests
test/runner/external-driver.test.ts(new, 8 cases), againsttest/runner/fixtures/fake-external-driver.mjs, a stand-in command that speaks the contract and reports what it saw of the key (a SHA-256, never the key):infonames the driver and version; a command exiting 4, printing prose, or missing is refused at construction with the reason.author: the exact stdin object, the call running in the project, the answer read into the turn (MCP prefix dropped,isErrorkept,model,numTurns,success), the project files snapshotted.ask: the config file is 0600, holds the URL and the key, the call runs in its directory, the key is on neither argv, environment nor stdin, and the file and its directory are gone afterwards.no-result(exit 3)and not measured; prose →invalid-output(stdout is not one JSON object); another shape →invalid-output(…)(is_error); a hang → killed at the timeout,author timed out after 0.03 min.external:with no command refused, the unknown-driver list; every flag inlimitsand on the record.crm_account_with_contactscard throughrunCard(both modes), each scripted turn sent through the stand-in command (the exporter fixture's in-memory app;runCrmgainskeyPrefixandwrap), every persona and the admin issued a keysk-scenario-e2e-key-9f27c1d4+ the persona id. Every ask read one of those keys from a 0600 file and from nowhere else, and each file is gone. Then the run record (where the CLI writes it), the recording, the scorecard (renderScorecard) and the full gallery export (exportGallery, which exported the card) are written, and every written file is searched for the key prefix: none holds it. The record namesexternal:fake-agent 1.2.3, the app page reads- Driver: external:fake-agent 1.2.3; a replay of that recording namesreplayOfand its page reads(re-graded from a recording of that run)without the recording's path.test/runner/codex-driver.test.ts(new, 12 cases), against a stand-incodexscript (it answers--version,login statuson stderr,mcp list --json, and forexecreads the profile it is pointed at):parseCodexJsonlon the 0.167.0 shapes (pairing, failed MCP call, command execution, a call cut short, torn last line, notice not an end,turn.failed).OPENAI_API_KEY/CODEX_API_KEYset, an API-key login, no login, an empty status, a non-plan login (its masked credential not echoed) refused; the billing variables stripped.codexProfileTomlexact text (TOML-escaped key and names).OPENAI_API_KEY; an ask turn's argv (exec --json --ephemeral --skip-git-repo-check, the two-coverrides,-s read-only,-), a 190 KB prompt on stdin, the profile 0600 with the key, the key on neither argv nor environment, the profile file gone and$CODEX_HOMEempty afterwards, no billing variable in the child; an author turn'sworkspace-write,-C, the network override and the user's server turned off; a user server namedapprefused; timeout, exit-without-result andturn.failedeach not measured;--model/--author-model/--ask-model→-m; both turn-cap flags refused.Ablations (each restored: blob == HEAD, git diff HEAD empty)
Both through
scripts/ablation-replace.mjs(anchor x1 → x0, replacement x0 → x1) on commitfb1d76f7. The suites importsrc/directly, so no dist leg.external.tsask:return await this.call(input, dir);→ the turn'smeta.modelset totask.mcp.apiKey): the end-to-end case →1 failed | 7 skipped,expected [ …(7) ] to deeply equal [], naming the run record,recording.json,scorecard.md, and the gallery'sREADME.md,run-record.json,scorecard.json,scorecard.md.codex.ts: the ChatGPT test widened to/Logged in using ChatGPT|API key configured/):codex-driver.test.ts -t "cost guard|refuses an API-key login"→2 failed | 2 passed, both "expected function to throw an error, but it didn't".Test Files 2 passed (2),Tests 20 passed (20).Acceptance notes
DriverInfo.apiBilledis typedfalse, and the runner cannot see an external command's login, so the record saysauthMethod: not verified (…)and the README states the cost ruling applies to the command; the four billing variables are stripped from its environment. Whether an external command must also be refused when one of them is set in the caller's environment (as the two built-in drivers are) was not in the rulings; this PR strips and does not refuse.modelis absent and the scorecard readsmodel not reported (asked for …)rather than guessing;modelMismatchis never set for it.$CODEX_HOME. The profile layer is the only key-in-a-file route the CLI was measured to read (-p); the file is 0600, uniquely named, and removed infinally. A run killed by SIGKILL could leave one behind; it holds a persona key of a local dev app that is torn down with the run.codex mcp list --jsonprints the user's other servers' headers to the runner's memory once at start; onlynameis read and nothing is logged.orchestrate.ts, the galleryindex.jsonschema (the driver is on the app page, as Ask 4 says;run-record.jsonalready carriesenv.driver).Verification
All on head
fb1d76f7(baseorigin/main169ff7e5, which carries #31221 asfba4c00aand #31204 as0d0c377b), worktreeobjectstack-issue-31159.pnpm --filter '@objectstack/scenarios^...' build(under the verify lock) →VERDICT command-exit 0.pnpm --filter @objectstack/scenarios build && pnpm --filter @objectstack/scenarios test→Test Files 30 passed (30),Tests 573 passed (573),VERDICT command-exit 0.pnpm --filter @objectstack/scenarios typecheck(tsc --noEmit, tests included) → exit 0.node --stack-size=4000 node_modules/eslint/bin/eslint.js packages/qa/scenarios --no-inline-config→ exit 0 (the package has nolintscript).require('dist/runner.cjs')(141 keys;ExternalDriver,CodexDriverfunctions),dist/export.cjs(driverText),dist/index.cjs,dist/cli.cjs, andimport('dist/runner.js')(EXTERNAL_DRIVER_CONTRACT=objectstack-scenario-driver/1).GITHUB_EVENT_NAME=pull_request GITHUB_EVENT_PATH=EVENT_WITH_THIS_BODY node scripts/check-changeset-no-major.mjs --base origin/main→ exit 0 (Clause-②: yes,Metadata-protocol: none,patch).Derived gates: 60 families, 58 run green, 2 NOT MEASURED, then 1 re-measured
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack(tree atfb1d76f7) → 60 commands, each run with its exit captured before any pipe;--ran→ "60 derived famil(ies) accounted for — 58 run, 2 NOT-MEASURED".node scripts/check-plugin-teardown-shape.mjs --self-test→ exit 3 (shallow clone, control commit missing). Aftergit fetch --depth=1 origin 621a4876…, rerun → exit 0, "48 cases pass".pnpm check:dual-build-cjs-loads→ exit 3, PREREQUISITE NOT MET (needs every package'sdist/; this worktree built the scenarios closure only). NOT MEASURED; the package's own CJS and ESM entries were loaded directly instead (above). CI runs it.pnpm --filter @objectstack/spec run check:error-code-provenance→ exit 0 (this diff adds no error-code literal).check:cross-package-test-inputs,check:test-source-alias,check:dts-closure,check:published-files,check:undeclared-dep-imports,check:type-check-debt,check:type-check-coverage,check:nul-bytes,check-changeset-no-major,check-empty-changeset,check-adr-0087-registration.pm-orders/devx/31159-gates-ran.txt(project files).test:repo, the dogfood battery and the full CI farm are CI's (no!in the title, no(narrowing)arm).Generated by Claude Code