Repository navigation
Hold App Server messages in tests to Codex's own schema - #3383
Merged
Merged
Conversation
The tests' App Server notifications were written by hand from what Leaf reads, so a fixture could carry a shape Codex never sends and still pass. The suite now generates Codex's protocol schema from the `@openai/codex` that `package.json` pins (`codex app-server generate-json-schema --experimental`, from `node_modules`, which `wt setup` installs), once per worker and uncommitted, and checks each message by its method: - `app_server_messages`, an autouse fixture, checks every message a test hands `AppServerEvents` or `TaskConnection`, whether a stand-in sent it or the test built it, and every message a test asks `app_server_delivery_id` about. A reader may run on its own thread, so what it finds, a check that could not run included, fails the test at its end; - the `app_server` stand-in checks what Leaf sends it (initialize, initialized, thread/start, thread/resume, thread/turns/list, turn/start, config/read) and what the stand-in sends back; - the website dispatch test checks the turn/interrupt and turn/start it captures and the completion its socket returns. Every request Leaf sends already held the schema. The fixtures did not: turns lacked `items` and `status`, command items their `command`, `commandActions`, `cwd` and `status`, item notifications their `threadId`, `turnId` and timestamps, thread statuses their `type` or `activeFlags`, a reasoning delta its `summaryIndex`, and approval and user-input requests were sent as notifications without an `id` or `itemId`. Each now carries what Codex sends. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The tests' App Server notifications were written by hand from what Leaf reads, so a fixture could carry a shape Codex never sends and still pass. This change is test-only.
Checking.
tests/conftest.pygenerates Codex's protocol schema from the@openai/codexthatpackage.jsonpins (codex app-server generate-json-schema --experimental, run fromnode_modules/.bin, whichwt setupinstalls locally and in CI), once per worker into a temporary directory, and checks each message against its method's branch:app_server_messages, an autouse fixture, checks every message a test handsAppServerEventsorTaskConnection(stand-in or hand-built) and every message a test asksapp_server_delivery_idabout. Readers can run on their own threads, so violations, and a check that could not run, are collected and fail the test at its end.app_serverstand-in (tests/interact_support.py) checks both directions: what Leaf sends it and what it sends back.turn/interruptandturn/startit captures and the completion its fake socket returns.Over the focused selection, Leaf's requests seen were
initialize,initialized,thread/start,thread/resume,thread/turns/list,turn/start,config/readandturn/interrupt; every one already held the schema, includingturn/start'stoolOutputandturnTrigger.Fixtures fixed. Turns lacked
itemsandstatus; command items theircommand,commandActions,cwdandstatus; item notifications theirthreadId,turnIdand timestamps; thread statuses theirtypeoractiveFlags; a reasoning delta itssummaryIndex; and approval and user-input requests were sent as notifications without anidoritemId. Most were added mechanically, so the diff intest_codex_app_server.pyis wide but changes no assertion.Not covered. Messages
leaf_websitereads in its own loops (for example_end_unfollowed_turn) from a test's fake socket are checked only where the test checks them, as the dispatch test now does. Responses ({id, result}) aren't checked, since their shape depends on the request.Checks: the focused Codex, thread-title, response, hook, stop-guard, delivery and website-server tests, pre-commit, and an independent Codex review. It found two gaps, both fixed:
app_server_delivery_idfixtures and the dispatch socket bypassed the check, and a failure to generate the schema would have been swallowed on a reader thread.tests/journeys/test_codex_adapter.py::test_codex_delivery_outlives_the_starting_command_and_acknowledgeserrors on main as well.