Skip to main content

Module codex_schema

Module codex_schema 

Source
Expand description

cargo xtask codex-schema <subcommand> — Rust port of the vendored codex-app-server-client crate’s former schema/build_combined_schema.py, plus staleness stamping and typify-panic bisection tooling.

Subcommands: regen Rebuild schema/protocol.schema.json + schema/methods.json from a fresh codex app-server generate-json-schema dump, and stamp the codex version the vendored schema was generated from. bisect Binary-search a fresh schema dump for the minimal definition(s) that panic typify’s schema-merge logic, the same failure mode documented for McpServerElicitationRequestParams in the crate’s README. drift Diff the vendored schema/methods.json against a fresh (or saved) codex app-server generate-json-schema dump and report added, removed, and changed methods per section - see drift.rs.

See crates/shared/codex-app-server-client/README.md’s “Regenerating the schema” section for the end-to-end workflow this drives.

Modules§

bisect 🔒
cargo xtask codex-schema bisect <dir> - binary-searches a fresh schema dump for the minimal definition(s) that panic typify’s schema-merge logic (typify-impl-0.7.0’s merge.rs:427, “not yet implemented” - the same failure mode McpServerElicitationRequestParams hit; see crates/shared/codex-app-server-client/README.md). Automates the “opaque out half the new/changed definitions, see if the panic goes away” process that was previously done by hand.
drift 🔒
cargo xtask codex-schema drift [--dir <dump-dir>] [--json] [--strict] - diffs the vendored schema/methods.json + schema/CODEX_VERSION.txt against a fresh codex app-server generate-json-schema dump (or an existing dump directory passed via --dir), so an upstream codex version bump that adds, removes, or renames a method can’t silently slip past the version-string-only staleness check in crates/shared/codex-app-server-client/build.rs.
merge 🔒
Core schema-merging logic - a faithful Rust port of the definitions- combining half of the former schema/build_combined_schema.py (see git history for the original). Reused by both regen (the real merge) and bisect (building opaqued-out candidate schemas from the same merge).
naming 🔒
Method-name -> Rust-identifier derivation, ported from build_combined_schema.py. Naming here must exactly match what typify names the corresponding generated Rust types/enum variants - this was empirically cross-validated against real typify output when this crate was first built, so keep it in lock-step with the Python original rather than “simplifying”.
regen 🔒
cargo xtask codex-schema regen <dir> - rebuilds the vendored schema assets from a fresh codex app-server generate-json-schema dump, and stamps the codex version they were generated from for staleness detection (see crates/shared/codex-app-server-client/build.rs).
typify_probe 🔒
Runs typify::TypeSpace::add_root_schema against a candidate schema inside catch_unwind, classifying the outcome so bisect can distinguish “converts fine”, “panics with the known typify-0.7.0 merge.rs:427 shape”, and “something else entirely” (a different panic, or an ordinary Result::Err).

Constants§

CODEX_VERSION_PATH 🔒
Workspace-relative path to the staleness-tracking codex version stamp (see regen::stamp_codex_version and build.rs’s staleness check).
MASTER_BUNDLE_FILE 🔒
Filename of the master (non-v2) schema bundle emitted by codex app-server generate-json-schema into its output directory. Shared by regen and bisect, which both read the same dump directory - must stay byte-identical between the two or one could silently start reading a stale/mismatched file.
METHODS_JSON_PATH 🔒
Workspace-relative path to the vendored per-method manifest.
PROTOCOL_SCHEMA_PATH 🔒
Workspace-relative path to the vendored combined protocol schema.
V2_BUNDLE_FILE 🔒
Filename of the v2-only schema bundle emitted alongside the master bundle. See MASTER_BUNDLE_FILE.

Functions§

load_combined_defs 🔒
Reads the master + v2 schema bundles from gen_dir, merges them via merge::build_combined, and extracts the flat definitions object. Shared by regen::regen (which writes the combined schema out) and bisect::bisect (which probes the definitions with typify).
parse_gen_dir 🔒
Parses the single positional <gen-dir> argument shared by the codex-schema regen and codex-schema bisect subcommands: --help/-h prints usage and exits 0 immediately, exactly one positional argument is accepted as the generated-schema directory, and any further positional argument is rejected. usage doubles as the error context when the positional argument is missing.
print_help 🔒
read_json 🔒
Reads and parses a JSON file, with file-path context on failure.
run