Skip to content

Cargo 工作空间全景

盘点 Codex Cargo 工作空间的全部 package、target 形态、职责分类与后续专题覆盖。

基于rust-v0.150.0
CodexRustCargoArchitecture

Cargo 工作空间全景 ​

Codex 的 Rust 工作空间不能用“codex-rs/ 下有多少目录”来计数。容器目录 ext/、memories/、utils/ 下还有嵌套 package,tests/common 也可以是 package; 反过来,.cargo/、docs/ 和 vendor/ 又不是 package。

对 Cargo 而言,准确答案来自 workspace manifest 和 cargo metadata。在这个版本中:

  • packages、workspace_members 和 workspace_default_members 都是 142;
  • 142 个 package 全部继承 workspace 版本 0.150.0、Rust 2024 edition 和 Apache-2.0 license;
  • 31 个 package 至少有一个 binary target,2 个是 proc-macro package,6 个有 build script;
  • 只有 codex-backend-client 显式设置 publish = [](禁止发布)。

本文的完整矩阵为每个 package 给出 manifest 路径、target 形态、直接职责和源码专题归类。 专题归类只用于导航,不代表 Cargo 依赖层级;真实依赖方向由 Crate依赖边界 单独建模。

本文是一份 Cargo/package 参考表,用于回答“某个 crate 在哪里、产生什么 target、归哪个专题”。一旦 问题进入函数调用、状态所有权或依赖边的运行含义,就应停止查矩阵,转入文末链接的专题正文;package 数量本身不能解释运行时架构。

1. Cargo metadata ​

本文使用 --no-deps,因为问题是“仓库自己定义了哪些 package”,而不是盘点 crates.io 依赖。该选项会保留 workspace package 的 manifest、target、feature 和发布属性, 同时不生成完整依赖 resolve 图。

bash
cargo metadata \
  --manifest-path codex-rs/Cargo.toml \
  --no-deps \
  --format-version 1 \
  > /tmp/codex-metadata.json

jq '{
  packages: (.packages | length),
  workspace_members: (.workspace_members | length),
  default_members: (.workspace_default_members | length)
}' /tmp/codex-metadata.json

输出的三个数字都是 142。后续矩阵直接使用 .packages[] 的 name、manifest_path 和 targets[].kind,避免对目录或二进制名做隐式推断。

Cargo.lock 在 --no-deps 清单中不会把外部依赖变成 workspace package;它的作用是锁定实际 解析的依赖版本。图中把 manifest 和 lockfile 分开,正是为了区分“我们定义的 package” 与“这些 package 解析到的依赖”。

根 manifest 的成员表直接体现了仓库如何把产品、协议、基础设施和扩展放进同一个解析单元。下面保留 一段连续源码,以免分类结论只来自生成后的矩阵:

源码位置:codex-rs/Cargo.toml :: [workspace].members(节选)

toml
[workspace]
members = [
    # 前几项既有共享服务,也有 App Server 产品边界。
    "aws-auth",
    "analytics",
    "agent-graph-store",
    "agent-identity",
    "backend-client",
    "bwrap",
    "ansi-escape",
    "async-utils",
    "app-server",
    "app-server-transport",
    "app-server-daemon",
    "app-server-client",
    "app-server-protocol",
    "app-server-protocol-noop-macros",
    "app-server-test-client",
    "apply-patch",
    "arg0",
    "feedback",
    "features",
    "install-context",
    "codex-backend-openapi-models",
    # Code Mode 被拆成协议、runtime、host 与产品入口多个 package。
    "code-mode",
    "code-mode-host",
    "code-mode-protocol",
    "code-mode-runtime",
    "codex-home",
    "cloud-config",
    "cloud-tasks",
    "cloud-tasks-client",
    "cloud-tasks-mock-client",
    "cli",
    "collaboration-mode-templates",
    "connectors",
    "config",
    "context-fragments",
    "shell-command",
    "shell-escalation",
    "skills",
    # core 与 core-api 同属 workspace,但后者只是面向宿主的 facade。
    "core",
    "core-api",
    "core-plugins",
    "core-skills",
    "hooks",
    "http-client",
    "secrets",
    "exec",
    "file-system",
    "exec-server-protocol",
    "exec-server",
    "exec-server/tests/support",
    "execpolicy",
    "ext/agent",
    "ext/connectors",
    "ext/extension-api",
    "ext/goal",
    "ext/git-attribution",
    "ext/guardian",
    "ext/image-generation",
    "ext/items",
    "ext/memories",
    "ext/mcp",
    "ext/skills",
    "ext/web-search",
    # ...
]
resolver = "2"

成员顺序本身不代表依赖层级,但连续出现的 app-server-*、code-mode-* 和 ext/* 能帮助读者先找到 专题边界。真正的边方向仍要交给 metadata resolve 图,而不能从列表相邻关系推断。

workspace 还统一了 package 元数据和内部 path dependency 的名称到路径映射:

源码位置:codex-rs/Cargo.toml :: [workspace.package], [workspace.dependencies](节选)

toml
[workspace.package]
version = "0.150.0"
# 新 crate 默认继承 2024 edition,个别 crate 仍可在自己的 manifest 覆盖。
edition = "2024"
license = "Apache-2.0"

[workspace.dependencies]
# Internal
app_test_support = { path = "app-server/tests/common" }
codex-analytics = { path = "analytics" }
codex-agent-graph-store = { path = "agent-graph-store" }
codex-agent-identity = { path = "agent-identity" }
codex-ansi-escape = { path = "ansi-escape" }
codex-api = { path = "codex-api" }
codex-aws-auth = { path = "aws-auth" }
codex-app-server = { path = "app-server" }
codex-app-server-transport = { path = "app-server-transport" }
codex-app-server-daemon = { path = "app-server-daemon" }
codex-app-server-client = { path = "app-server-client" }
codex-app-server-protocol = { path = "app-server-protocol" }
codex-app-server-test-client = { path = "app-server-test-client" }
codex-apply-patch = { path = "apply-patch" }
codex-arg0 = { path = "arg0" }
codex-async-utils = { path = "async-utils" }
codex-backend-client = { path = "backend-client" }
codex-chatgpt = { path = "chatgpt" }
codex-cli = { path = "cli" }
codex-client = { path = "codex-client" }
codex-cloud-config = { path = "cloud-config" }
codex-code-mode = { path = "code-mode" }
codex-code-mode-protocol = { path = "code-mode-protocol" }
codex-code-mode-runtime = { path = "code-mode-runtime" }
codex-config = { path = "config" }
codex-connectors = { path = "connectors" }
codex-context-fragments = { path = "context-fragments" }
codex-core = { path = "core" }
codex-core-api = { path = "core-api" }
codex-core-plugins = { path = "core-plugins" }
codex-core-skills = { path = "core-skills" }
# ...

members 决定谁属于 workspace;workspace.dependencies 决定成员 manifest 使用的统一 dependency key。 两者共同解释为什么 package 名、目录名和依赖名并不总是一一相同。

2. Manifest清单 ​

[workspace].members 数组显式写了 136 个路径。另外 6 个 manifest 位于 workspace 根下、 继承 version.workspace、edition.workspace 和 license.workspace,并被 workspace package 通过路径依赖 或工程配置纳入。Cargo metadata 将它们一并列入 workspace_members。

metadata packagemanifest 目录角色
app_test_supportapp-server/tests/common/App Server 集成测试公共库
codex-chatgptchatgpt/第一方 ChatGPT/Codex 产品能力
core_test_supportcore/tests/common/Core 集成测试公共库
mcp_test_supportmcp-server/tests/common/MCP Server 集成测试公共库
codex-message-historymessage-history/本地消息历史持久化
codex-windows-sandboxwindows-sandbox-rs/Windows sandbox 库与两个辅助二进制

因此,升级 tag 时不能只对 members = [...] 做文本 diff。新增一个位于 workspace 根内的 路径 package,可能在没有增加数组行的情况下改变 metadata 清单。

3. Package与Target ​

Cargo package 是一个 manifest 边界;它可以同时产生 library、binary、integration test、example、 benchmark 或 build script target。该版本的 package target 组合如下:

cargo metadata 的对象关系解释了为什么目录数、package 数和 binary 数不能互换。下面的类型名对应 metadata 返回结构中的真实概念。

一个 Package 可以组合多个 Target,依赖边则挂在 package 而不是 binary 上。本文的 142 个节点因此 来自 Metadata.packages,31 个含 binary 的 package 还会继续展开为更多 target。

target kind 组合package 数解读
lib93只有 library target;仍可在 src 内包含 unit tests
lib+test15library 加显式 integration-test target
bin+lib+test11同时提供库、二进制和 integration test
bin+lib5库和二进制
bin+custom-build+lib+test2CLI 或 Linux sandbox 还需要 build script
proc-macro2过程宏 package
bench+lib1图像工具库带 benchmark
bin1只有演示二进制
bin+custom-build1构建并输出捆绑 bubblewrap
bin+custom-build+lib1Windows sandbox 库、helper 二进制与 build script
custom-build+lib1skills 库在构建时准备内置资产
example+lib1config 库附带示例
example+lib+test1extension API 附带示例和显式测试

其中“31 个 package 包含 binary”不表示 Codex 对用户提供 31 个稳定命令。 codex-app-server、codex-rmcp-client 和 codex-tui 等 package 还包含测试服务器、fixture generator 或辅助调试 binary。产品入口要继续查看 targets[].name、CLI 分派和打包脚本。

三个短 manifest 片段可以校准 metadata 字段的真实含义。codex-core 同时生成 library 和 schema writer binary;codex-core-api 关闭自己的 test/doctest target;codex-backend-client 则显式禁止发布。

源码位置:codex-rs/core/Cargo.toml :: [lib], [[bin]]

toml
[lib]
name = "codex_core"
path = "src/lib.rs"

# package含bin不等于bin就是面向终端用户的稳定产品命令。
[[bin]]
name = "codex-write-config-schema"
path = "src/bin/config_schema.rs"

facade package 则展示另一种 lib target 配置:它依赖下游 consumer 编译验证,不创建自己的测试 harness。

源码位置:codex-rs/core-api/Cargo.toml :: [lib]

toml
[lib]
doctest = false
name = "codex_core_api"
path = "src/lib.rs"
# test=false只关闭该lib target的测试harness,不代表底层Core没有测试。
test = false

发布属性属于 package 元数据,与 target 组合正交。当前唯一显式关闭发布的 manifest 如下:

源码位置:codex-rs/backend-client/Cargo.toml :: [package]

toml
[package]
name = "codex-backend-client"
version.workspace = true
edition.workspace = true
license.workspace = true
# metadata中publish=[]来自这个显式配置。
publish = []

4. 按源码职责归类 ​

完整矩阵按源码职责分成 16 类。跨模块概览和版本差异不直接对应某个 package;其余 package 按最主要的行为边界归类。

源码职责类package 数归类依据常见交叉类
Multi-Agent4多 Agent 拓扑、协作模式与 GoalPersistence、Extensions
App Server7App Server 服务、client、transport 与 daemonProtocol、Core Runtime
Protocol6跨 crate/进程共享类型与路径 wire typeApp Server、Execution
Execution13进程、PTY、文件、Code Mode 与 Exec ServerTools、Security
Security13策略、沙箱、凭据、网络与进程强制Execution、Config/Auth
CLI9顶层命令、非交互入口和云任务Core Runtime、Model
Core Runtime7Thread/Turn 核心编排与通用异步基础Context、Model
Model14provider、HTTP/SSE/WebSocket、本地模型与后端 APICore Runtime、Config/Auth
Context4上下文片段、prompt、模板和预算截断Core Runtime、Tools
Tools2模型可见工具合约与文件搜索Execution、Extensions
Extensions22Plugin、Skill、Hook、Connector、MCP 与扩展 crateMulti-Agent、Config/Auth
Persistence7Thread、rollout、memory、message 与 SQLite 持久化Core Runtime、Observability
Config/Auth11配置层、feature、认证、CODEX_HOME 与安装环境Security、CLI
Observability6analytics、OTel、feedback 和本地诊断Core Runtime、Persistence
TUI7终端 UI、ANSI、媒体处理和休眠抑制CLI、Core Runtime
Build/Test3跨 Cargo/Bazel 测试支持与 binary 定位多个职责域

例如 codex-app-server-protocol 的内容是协议,但主要服务于 App Server;本矩阵将它放入 Protocol,App Server 文章通过交叉引用使用它。codex-agent-graph-store 则归 Multi-Agent,但其本地存储 实现仍是 Persistence 的证据。这种“一个主要职责 + 多个交叉使用者”避免同一 crate 被重复解释。

5. Package覆盖矩阵 ​

Target 列只列 metadata 中出现的 kind;test 指独立 test target,不包括编译在 library 内的 #[cfg(test)] unit test。路径全部相对 codex-rs/。

5.1 核心服务 ​

PackageManifest 路径Target直接职责源码职责类
codex-async-utilsasync-utilslib提供异步任务、取消与 channel 通用工具Core Runtime
codex-core-apicore-apilib向产品入口暴露稳定的 Thread 管理 facadeCore Runtime
codex-corecorebin+lib+test实现 Session、Turn、模型循环与工具编排Core Runtime
codex-utils-cacheutils/cachelib提供异步与阻塞 LRU 缓存辅助Core Runtime
codex-utils-readinessutils/readinesslib提供带授权 token 的异步就绪状态Core Runtime
codex-utils-stringutils/stringlib提供 JSON 字符串与 token 预算截断工具Core Runtime
codex-thread-manager-samplethread-manager-samplebin演示如何嵌入并调用 ThreadManagerCore Runtime
codex-context-fragmentscontext-fragmentslib定义有界、可组合的模型上下文片段Context
codex-promptspromptslib集中提供压缩、审查、权限与 Goal promptsContext
codex-utils-output-truncationutils/output-truncationlib按 token 或字符预算截断工具与执行输出Context
codex-utils-templateutils/templatelib严格解析并渲染文本模板占位符Context
codex-aws-authaws-authlib实现 AWS 凭据加载与 SigV4 请求签名Model
codex-backend-clientbackend-clientlib封装 Codex 后端账户、任务与设置 APIModel
codex-apicodex-apilib+test实现 Responses、Compact 与 Memories 类型化 APIModel
codex-backend-openapi-modelscodex-backend-openapi-modelslib保存后端 OpenAPI 生成模型Model
codex-clientcodex-clientlib提供通用 HTTP 重试、退避与 SSE 策略Model
codex-http-clienthttp-clientbin+lib+test提供路由感知、代理感知的底层 HTTP transportModel
codex-lmstudiolmstudiolib封装 LM Studio 本地模型发现与默认值Model
codex-model-provider-infomodel-provider-infolib管理内置及用户定义的模型 provider 配置Model
codex-model-providermodel-providerlib定义模型 provider 运行接口与实现桥接Model
codex-models-managermodels-managerlib加载、缓存并筛选模型目录与预设Model
codex-ollamaollamalib封装 Ollama 本地模型发现与默认值Model
codex-utils-ossutils/osslib共享 TUI 和 Exec 的本地 OSS provider 选择逻辑Model
codex-utils-stream-parserutils/stream-parserlib增量解析流式文本、隐藏标签与引用Model
codex-websocket-clientwebsocket-clientlib提供带策略配置的 WebSocket clientModel
codex-app-server-protocol-noop-macrosapp-server-protocol-noop-macrosproc-macro在无需导出时提供 App Server 协议空过程宏Protocol
codex-app-server-protocolapp-server-protocollib定义 App Server 请求、响应、通知与 schema 导出Protocol
codex-experimental-api-macroscodex-experimental-api-macrosproc-macro标记并控制实验 API 的过程宏Protocol
codex-protocolprotocollib定义 Core 的 Op、Event、模型与配置协议类型Protocol
codex-utils-absolute-pathutils/absolute-pathlib提供已验证绝对路径类型与跨平台规范化Protocol
codex-utils-path-uriutils/path-urilib提供可序列化的跨平台 file URI 路径类型Protocol
codex-app-server-clientapp-server-clientlib供 TUI 与 Exec 复用进程内 App Server 客户端App Server
codex-app-server-daemonapp-server-daemonlib管理 Unix App Server 守护进程生命周期App Server
codex-app-server-test-clientapp-server-test-clientbin+lib提供独立 App Server 协议测试客户端App Server
codex-app-server-transportapp-server-transportlib实现 stdio、WebSocket、UDS 与远程控制 transportApp Server
codex-app-serverapp-serverbin+lib+test实现 App Server 请求处理、状态与对外服务App Server
app_test_supportapp-server/tests/commonlib共享 App Server 集成测试夹具与客户端App Server
codex-udsudslib封装跨平台异步 Unix Domain SocketApp Server

5.2 入口与执行 ​

PackageManifest 路径Target直接职责源码职责类
codex-arg0arg0lib依据 argv0 或特殊参数分派内置辅助入口CLI
codex-chatgptchatgptlib+test封装第一方 ChatGPT/Codex 产品命令能力CLI
codex-cliclibin+custom-build+lib+test定义顶层 codex 多命令入口与分派CLI
codex-cloud-tasks-clientcloud-tasks-clientlib定义云任务后端接口与 HTTP 客户端CLI
codex-cloud-tasks-mock-clientcloud-tasks-mock-clientlib提供云任务测试用 mock clientCLI
codex-cloud-taskscloud-taskslib+test实现云任务列表、创建、应用与终端 UICLI
codex-execexecbin+lib+test实现非交互 codex exec 和 review 客户端CLI
codex-responses-api-proxyresponses-api-proxybin+lib提供 Responses API 本地代理进程CLI
codex-utils-cliutils/clilib共享审批、沙箱、恢复和配置覆盖 CLI 参数CLI
codex-ansi-escapeansi-escapelib把 ANSI 输出转换为 ratatui 文本TUI
codex-terminal-detectionterminal-detectionlib识别终端类型并提供 TUI 和遥测元数据TUI
codex-tuituibin+lib+test实现交互式终端应用、事件循环与组件TUI
codex-utils-audioutils/audiolib准备音频模型输入并估算 tokenTUI
codex-utils-fuzzy-matchutils/fuzzy-matchlib提供 Unicode 安全的模糊匹配与高亮TUI
codex-utils-imageutils/imagebench+lib解码、缩放、缓存并规范化图像输入TUI
codex-utils-sleep-inhibitorutils/sleep-inhibitorlib在 Turn 运行期间跨平台阻止系统休眠TUI
codex-file-searchfile-searchbin+lib按 gitignore 遍历并模糊搜索工作区文件Tools
codex-toolstoolslib+test定义共享 ToolSpec、ToolExecutor 与工具适配器Tools
codex-apply-patchapply-patchbin+lib+test解析、验证并应用 apply_patch 补丁Execution
codex-code-mode-hostcode-mode-hostbin+lib+test托管独立 Code Mode V8 会话与传输Execution
codex-code-mode-protocolcode-mode-protocollib定义 Code Mode host、runtime 与 cell 协议Execution
codex-code-mode-runtimecode-mode-runtimelib+test实现进程内 V8 Code Mode cell runtimeExecution
codex-code-modecode-modelib选择进程内、进程拥有或远程 Code Mode 会话Execution
codex-exec-server-protocolexec-server-protocollib定义远程进程、文件与 HTTP 执行协议Execution
codex-exec-serverexec-serverlib+test实现本地或远程执行环境服务Execution
codex-exec-server-test-supportexec-server/tests/supportlib共享 Exec Server 集成测试环境Execution
codex-file-systemfile-systemlib实现执行环境文件系统与权限模型Execution
codex-git-utilsgit-utilslib提供 Git 根目录、分支、diff 与仓库操作Execution
codex-utils-pathutils/path-utilslib提供路径规范化、符号链接解析与原子写入Execution
codex-utils-ptyutils/ptylib统一 PTY 与 pipe 子进程控制Execution
codex-v8-pocv8-poclib验证 V8 嵌入与沙箱能力的实验库Execution
codex-agent-identityagent-identitylib生成、注册并验证 Agent 身份密钥与令牌Security
codex-bwrapbwrapbin+custom-build构建随发行包交付的 bubblewrap 二进制Security
codex-execpolicyexecpolicybin+lib+test用 Starlark 前缀规则判定命令执行策略Security
codex-linux-sandboxlinux-sandboxbin+custom-build+lib+test实现 Linux Landlock 与 bubblewrap 沙箱入口Security
codex-network-proxynetwork-proxylib+test实现受策略约束的网络代理与请求转发Security
codex-process-hardeningprocess-hardeninglib应用平台进程加固与危险能力收缩Security
codex-sandboxingsandboxinglib共享沙箱策略转换与命令构造Security
codex-secretssecretslib识别、包装并安全处理敏感值Security
codex-shell-commandshell-commandlib解析 shell 命令并提取安全判定信息Security
codex-shell-escalationshell-escalationbin+lib实现 execve 包装与 shell 权限提升链路Security
codex-utils-rustls-providerutils/rustls-providerlib+test安装进程级 rustls 加密 providerSecurity
codex-utils-sandbox-summaryutils/sandbox-summarylib把权限配置与沙箱策略转为可读摘要Security
codex-windows-sandboxwindows-sandbox-rsbin+custom-build+lib实现 Windows 沙箱服务、runner 与 setup 工具Security

5.3 扩展与配置 ​

PackageManifest 路径Target直接职责源码职责类
codex-mcpcodex-mcplib编排 MCP runtime、目录、资源与 elicitationExtensions
codex-connectorsconnectorslib管理 App connector 元数据、策略与 runtimeExtensions
codex-core-pluginscore-pluginslib加载、同步并管理 marketplace 和 plugin 生命周期Extensions
codex-core-skillscore-skillslib+test加载、过滤并注入产品可见 skillsExtensions
codex-connectors-extensionext/connectorslib把 connectors 暴露为扩展能力Extensions
codex-extension-apiext/extension-apiexample+lib+test定义扩展注册、发现与执行公共 APIExtensions
codex-git-attributionext/git-attributionlib提供扩展脚本和变更的 Git 归因Extensions
codex-guardianext/guardianlib提供 Guardian 审查扩展与策略桥接Extensions
codex-image-generation-extensionext/image-generationlib实现图像生成扩展工具Extensions
codex-extension-itemsext/itemslib定义扩展共享 item 类型Extensions
codex-mcp-extensionext/mcplib+test把 MCP 能力注册为扩展Extensions
codex-skills-extensionext/skillslib+test把 skill 发现与读取注册为扩展Extensions
codex-web-search-extensionext/web-searchlib实现 Web Search 扩展工具Extensions
codex-external-agent-migrationexternal-agent-migrationlib检测并迁移外部 Agent 配置与会话Extensions
codex-hookshooksbin+lib定义 hook 声明、事件、执行引擎与 schemaExtensions
codex-mcp-servermcp-serverbin+lib+test把 Codex 暴露为 MCP serverExtensions
mcp_test_supportmcp-server/tests/commonlib共享 MCP Server 集成测试夹具Extensions
codex-pluginpluginlib定义 plugin 包、标识、来源与解析模型Extensions
codex-rmcp-clientrmcp-clientbin+lib+test实现 MCP transport、OAuth 与协议模式客户端Extensions
codex-skillsskillscustom-build+lib实现底层 skill 扫描、索引和隐式匹配Extensions
codex-stdio-to-udsstdio-to-udsbin+lib+test在 MCP stdio 与 Unix Socket 之间转接Extensions
codex-utils-pluginsutils/pluginslib共享 plugin 路径、mention 与 connector 工具Extensions
codex-agent-graph-storeagent-graph-storelib存储由线程派生的父子 Agent 拓扑Multi-Agent
codex-collaboration-mode-templatescollaboration-mode-templateslib编译内置默认与计划协作模式模板Multi-Agent
codex-agent-extensionext/agentlib+test提供 Agent 扩展及多 Agent 工具桥接Multi-Agent
codex-goal-extensionext/goallib+test提供 Goal 扩展的读取与更新能力Multi-Agent
codex-memories-extensionext/memorieslib把 memory 能力注册为扩展Persistence
codex-memories-readmemories/readlib注入记忆指令并解析 memory citationsPersistence
codex-memories-writememories/writelib实现两阶段记忆提取与合并辅助Persistence
codex-message-historymessage-historylib持久化并读取本地消息历史Persistence
codex-rolloutrolloutlib记录、发现、压缩并维护会话 JSONLPersistence
codex-statestatelib用 SQLite 镜像 rollout 元数据与作业状态Persistence
codex-thread-storethread-storelib抽象 Thread 历史与元数据存储边界Persistence
codex-cloud-configcloud-configlib加载、验证、缓存并刷新云端配置Config/Auth
codex-configconfigexample+lib解析并合并多层 Codex 配置Config/Auth
codex-featuresfeatureslib集中注册并解析 feature flagsConfig/Auth
codex-file-watcherfile-watcherlib订阅文件变化并按所有者路由通知Config/Auth
codex-homecodex-homelib定位和管理 CODEX_HOME 目录边界Config/Auth
codex-install-contextinstall-contextlib识别 standalone package 布局与安装方式Config/Auth
codex-keyring-storekeyring-storelib通过系统 keyring 保存凭据Config/Auth
codex-loginloginlib+test实现 API key、ChatGPT 与设备码认证Config/Auth
codex-utils-approval-presetsutils/approval-presetslib组合内置审批策略与权限 profileConfig/Auth
codex-utils-home-dirutils/home-dirlib解析并校验 CODEX_HOME 与用户目录Config/Auth
codex-utils-json-to-tomlutils/json-to-tomllib把 JSON 配置值转换为 TOMLConfig/Auth
codex-analyticsanalyticslib归约并发送 Codex 产品分析事件Observability
codex-feedbackfeedbacklib收集、打包并上传用户反馈附件Observability
codex-otelotellib+test配置日志、指标与 OpenTelemetry 导出Observability
codex-response-debug-contextresponse-debug-contextlib从 API 错误提取请求与代理诊断头Observability
codex-rollout-tracerollout-tracelib记录并离线归约本地 rollout 调试图Observability
codex-utils-elapsedutils/elapsedlib格式化紧凑的人类可读耗时Observability

5.4 测试基础设施 ​

PackageManifest 路径Target直接职责源码职责类
core_test_supportcore/tests/commonlib共享 Core 集成测试服务器、fixture 与 builderBuild/Test
codex-test-binary-supporttest-binary-supportlib提供测试辅助二进制的共享实现Build/Test
codex-utils-cargo-binutils/cargo-binlib统一 Cargo/Bazel 测试二进制与 runfile 定位Build/Test

6. 升级矩阵 ​

矩阵的可维护单元是 package name,而不是行号或当前排序位置。跟进新 tag 时,先比较 metadata 集合,再审查变更 package 的 manifest、target 和职责:

新增一个 utils/ package 可能只改变一个局部 consumer;删除 codex-protocol 或改变 codex-core target 则会影响多条依赖链。package 集合、manifest diff 和依赖图三者结合,才能判断实际影响范围。

7. 重建全部统计 ​

以下命令重新执行 metadata 查询,结果用于生成本文矩阵。以下命令 均从 Codex 仓库根运行,--no-deps 明确只研究 workspace package,不把 crates.io 节点加入清单。

bash
# 生成一次metadata;临时文件不属于仓库资产。
cargo metadata --manifest-path codex-rs/Cargo.toml \
  --no-deps --format-version 1 > /tmp/codex-metadata.json

# package/member、target形态和统一元数据。
jq '{
  packages: (.packages | length),
  members: (.workspace_members | length),
  defaults: (.workspace_default_members | length),
  with_bin: ([.packages[] | select(any(.targets[]; .kind | index("bin")))] | length),
  proc_macro: ([.packages[] | select(any(.targets[]; .kind | index("proc-macro")))] | length),
  custom_build: ([.packages[] | select(any(.targets[]; .kind | index("custom-build")))] | length),
  explicit_test: ([.packages[] | select(any(.targets[]; .kind | index("test")))] | length),
  versions: ([.packages[].version] | unique),
  editions: ([.packages[].edition] | unique),
  licenses: ([.packages[].license] | unique),
  publish_false: [.packages[] | select(.publish == []) | .name]
}' /tmp/codex-metadata.json

# manifest文本中显式member路径数;Cargo还会纳入workspace根内路径package。
python3 -c 'import pathlib,tomllib; d=tomllib.loads(pathlib.Path("codex-rs/Cargo.toml").read_text()); print(len(d["workspace"]["members"]))'

# 按每个package的target kind并集分组,重建第3节表格。
jq '[.packages[] | ([.targets[].kind[]] | unique | sort | join("+"))]
    | group_by(.) | map({kind: .[0], count: length}) | sort_by(-.count)' \
  /tmp/codex-metadata.json
查询结果数值
packages / members / defaults142 / 142 / 142
含 bin / proc-macro / custom-build / explicit test 的 package31 / 2 / 6 / 32
unique version / edition / license0.150.0 / 2024 / Apache-2.0
显式 workspace.members 路径136
publish = []仅 codex-backend-client

这里的 explicit_test=29 只统计 metadata target,不包含 library 内的 #[cfg(test)];with_bin=21 也只 说明存在 binary target,不说明打包脚本会交付它。升级时若数字变化,应继续查看 package name、manifest path 和 target name 的集合 diff,而不是只修改总数。

7.1 统计适用范围 ​

重建命令的输入是 workspace manifest,动作是让 Cargo 输出 package、member 和 target 集合,再用 jq 按字段归约;关键断言是三组数量相等、版本/edition/license 各只有一个值,以及 package 集合与 正文矩阵的差集为空。它能证明当前 workspace 的静态清单与矩阵一致,不能证明依赖方向、代码是否真的 使用某个 target,也不能证明 binary 会被打包进某个平台安装包。需要回答后两个问题时,分别转到 Crate依赖边界 和对应的构建/发布源码。

8. Package专题 ​

已定位的package或问题对应专题正文停止查矩阵的条件
codex-core、codex-core-apiCore与Core-API边界已确定宿主facade或内部实现
codex-core 内的Thread/TurnCore运行时架构总览开始追踪状态与调用链
thread-manager-sample、manager依赖ThreadManager依赖已定位manager owner
app-server-*、TUI、Exec、Build/TestCodex 产品形态全景已确定连接寿命和transport
crate真实依赖方向Crate依赖边界需要回答“谁依赖谁”
sandbox、exec、platform packageCodex信任边界、跨平台能力矩阵已选定强制后端与平台
feature/config packageCore运行时能力开关开始分析effective gate
test/support/schema target源码测试与生成物地图已找到具体测试或generator
新tag改变了哪些consumerCodex源码阅读路线已定位受影响的调用链

本矩阵给 package 分配源码职责类只是导航。例如 codex-app-server-protocol 归 Protocol,不表示 App Server 不能 消费它;真实依赖边和稳定边界以 Crate依赖边界 的 metadata resolve 图为准。