Codex Source Review
Objective
Review only for one goal: maximize compatibility with upstream Codex so future upstream updates are easy to adopt.
Reuse Priority
Judge every implementation choice against this order:
import external
copy/paste raw code
mock/inject
edit codex source code
implement by ourself
Treat a lower-priority choice as a finding unless the code shows a concrete reason the higher-priority choices cannot work.
Review Workflow
Establish the upstream baseline before judging the implementation.
- Locate
external/codex or the configured upstream Codex checkout.
- Record the submodule commit or upstream revision if available.
- Inspect the relevant upstream files with
rg, git diff, and targeted file reads.
Map changed code to upstream behavior.
- Identify the feature under review: turn loop, model request/Responses events, tools,
apply_patch, exec, approvals, history, config, or storage.
- Find the closest upstream files and functions.
- Classify each local implementation by the reuse priority above.
Check for avoidable divergence.
- Prefer path dependency/import of upstream crates or modules when wasm-compatible.
- Prefer raw copied upstream code when imports pull native-only dependencies.
- Allow mocks/injection only at host boundaries such as model transport, filesystem, exec, storage, approvals, browser APIs, and WebContainer.
- Treat custom reimplementation of agent logic, tool routing, event handling, prompt/history construction, or patch semantics as high risk.
Check modifications to upstream Codex.
- Treat edits under
external/codex as destructive unless they are isolated, minimal, and clearly necessary.
- Prefer local adapters, feature gates, or upstreamable patches over changing vendored source.
- Verify any upstream edit preserves 100% behavior for native Codex paths unless the user explicitly accepts a fork.
Check source-reference comments.
- Require a nearby code comment for any custom implementation, copied upstream block, or destructive upstream-source modification.
- The comment must name the upstream file and function/module being followed.
- The comment must explain the allowed divergence, if any.
- Do not require these comments for ordinary imports that directly use upstream code.
Good comment pattern:
// Mirrors upstream Codex: external/codex/codex-rs/core/src/session/turn.rs::run_turn.
// Divergence: model transport is injected through HostModelClient because wasm cannot use the native client.
Good copy/paste comment pattern:
// Copied from upstream Codex: external/codex/codex-rs/core/src/tools/router.rs.
// Keep semantics aligned; only Send/Sync bounds are relaxed for wasm host callbacks.
Findings To Prioritize
Report these as review findings when present:
- A lower-priority reuse strategy is used without evidence that higher-priority strategies fail.
- Custom code implements behavior already available from upstream Codex.
- Copied upstream code has semantic edits that are not documented or tested against upstream.
- Mocks replace core agent behavior instead of host capabilities.
external/codex is modified without a narrow, necessary, upstream-compatible reason.
- Custom or modified code lacks an upstream source-reference comment.
- Tests validate only local behavior and do not compare against upstream Codex fixtures, traces, or oracle behavior.
- Provider compatibility code is mixed into conformance logic instead of isolated behind an adapter.
Allowed Divergence
Accept divergence only when it is necessary for the browser/wasm runtime and isolated behind a boundary:
- WebContainer filesystem and process execution adapters.
- Browser storage adapters such as Turso or in-memory storage.
- Browser
fetch, stream, Promise, and wasm-bindgen bindings.
- Provider adapters for non-OpenAI Responses-compatible models.
- Permission UI or approval transport, as long as core approval semantics match upstream.
Even when allowed, require a reference to the upstream Codex behavior being preserved.
Review Output
Use a code-review format. Findings come first, ordered by severity.
For each finding include:
- Severity:
P0, P1, P2, or P3.
- Local file and line.
- Upstream reference file/function.
- Which reuse-priority rule was violated.
- Why the divergence risks future upstream compatibility.
- Concrete fix: import, copy raw code, inject host boundary, remove upstream edit, add comment, or add upstream oracle test.
After findings, include:
- Open questions or assumptions.
- A short compatibility summary: import/copy/mock/edit/custom counts if useful.
- Test gaps, especially missing upstream oracle, fixture, or trace comparisons.
If there are no findings, say so directly and still mention any residual test gaps.
1---2name: codex-source-review3description: Review implementations that aim to stay compatible with upstream OpenAI Codex source. Use when Codex is asked to review or audit code, PRs, diffs, plans, or architecture for browser/wasm Codex agent work, especially to check reuse of external/codex, copy/paste fidelity, mock/injection boundaries, destructive upstream source edits, custom implementations, and source-reference comments pointing to upstream Codex files.4---56# Codex Source Review78## Objective910Review only for one goal: maximize compatibility with upstream Codex so future upstream updates are easy to adopt.1112## Reuse Priority1314Judge every implementation choice against this order:15161. `import external`172. `copy/paste raw code`183. `mock/inject`194. `edit codex source code`205. `implement by ourself`2122Treat a lower-priority choice as a finding unless the code shows a concrete reason the higher-priority choices cannot work.2324## Review Workflow25261. Establish the upstream baseline before judging the implementation.27 - Locate `external/codex` or the configured upstream Codex checkout.28 - Record the submodule commit or upstream revision if available.29 - Inspect the relevant upstream files with `rg`, `git diff`, and targeted file reads.30312. Map changed code to upstream behavior.32 - Identify the feature under review: turn loop, model request/Responses events, tools, `apply_patch`, exec, approvals, history, config, or storage.33 - Find the closest upstream files and functions.34 - Classify each local implementation by the reuse priority above.35363. Check for avoidable divergence.37 - Prefer path dependency/import of upstream crates or modules when wasm-compatible.38 - Prefer raw copied upstream code when imports pull native-only dependencies.39 - Allow mocks/injection only at host boundaries such as model transport, filesystem, exec, storage, approvals, browser APIs, and WebContainer.40 - Treat custom reimplementation of agent logic, tool routing, event handling, prompt/history construction, or patch semantics as high risk.41424. Check modifications to upstream Codex.43 - Treat edits under `external/codex` as destructive unless they are isolated, minimal, and clearly necessary.44 - Prefer local adapters, feature gates, or upstreamable patches over changing vendored source.45 - Verify any upstream edit preserves 100% behavior for native Codex paths unless the user explicitly accepts a fork.46475. Check source-reference comments.48 - Require a nearby code comment for any custom implementation, copied upstream block, or destructive upstream-source modification.49 - The comment must name the upstream file and function/module being followed.50 - The comment must explain the allowed divergence, if any.51 - Do not require these comments for ordinary imports that directly use upstream code.5253Good comment pattern:5455```rust56// Mirrors upstream Codex: external/codex/codex-rs/core/src/session/turn.rs::run_turn.57// Divergence: model transport is injected through HostModelClient because wasm cannot use the native client.58```5960Good copy/paste comment pattern:6162```rust63// Copied from upstream Codex: external/codex/codex-rs/core/src/tools/router.rs.64// Keep semantics aligned; only Send/Sync bounds are relaxed for wasm host callbacks.65```6667## Findings To Prioritize6869Report these as review findings when present:7071- A lower-priority reuse strategy is used without evidence that higher-priority strategies fail.72- Custom code implements behavior already available from upstream Codex.73- Copied upstream code has semantic edits that are not documented or tested against upstream.74- Mocks replace core agent behavior instead of host capabilities.75- `external/codex` is modified without a narrow, necessary, upstream-compatible reason.76- Custom or modified code lacks an upstream source-reference comment.77- Tests validate only local behavior and do not compare against upstream Codex fixtures, traces, or oracle behavior.78- Provider compatibility code is mixed into conformance logic instead of isolated behind an adapter.7980## Allowed Divergence8182Accept divergence only when it is necessary for the browser/wasm runtime and isolated behind a boundary:8384- WebContainer filesystem and process execution adapters.85- Browser storage adapters such as Turso or in-memory storage.86- Browser `fetch`, stream, Promise, and `wasm-bindgen` bindings.87- Provider adapters for non-OpenAI Responses-compatible models.88- Permission UI or approval transport, as long as core approval semantics match upstream.8990Even when allowed, require a reference to the upstream Codex behavior being preserved.9192## Review Output9394Use a code-review format. Findings come first, ordered by severity.9596For each finding include:9798- Severity: `P0`, `P1`, `P2`, or `P3`.99- Local file and line.100- Upstream reference file/function.101- Which reuse-priority rule was violated.102- Why the divergence risks future upstream compatibility.103- Concrete fix: import, copy raw code, inject host boundary, remove upstream edit, add comment, or add upstream oracle test.104105After findings, include:106107- Open questions or assumptions.108- A short compatibility summary: import/copy/mock/edit/custom counts if useful.109- Test gaps, especially missing upstream oracle, fixture, or trace comparisons.110111If there are no findings, say so directly and still mention any residual test gaps.