1实现原理 · 为什么它能做到
读的是 Codex 三种互不替代的历史面:history.jsonl(prompt ledger,用户提交原文)、state_*.sqlite(清单元数据)、sessions|archived_sessions 下的 rollout-*.jsonl(完整事件流);每类查询路由到专用脚本,禁止 ad-hoc 重造 join。
| `<codex-home>/history.jsonl` | What the user submitted, keyed by Session ID and internal epoch timestamp | Exact recent user-input tables |
身份与血统门禁(Identity and lineage gate):每条行为结论前必须 (1) 核对 prompt-ledger Session ID、(2) 按内部 session_meta.id 而非文件名定位 rollout、(3) 解析后要求 session_meta.id == 请求 ID、(4) fork 边要声明的父 ID + 精确 history_base.end_byte_offset,拒绝缺失/歧义/循环/不匹配的祖先。
Locate rollout candidates by their internal `session_meta.id`, not filename alone.
sqlite 读取被强制只读:_core/codex.py 用 file: URI ?mode=ro 连接并 PRAGMA query_only=ON,schema 不兼容时降级为原生 rollout JSONL 扫描。
return "file:" + quote(path.resolve().as_posix(), safe="/:@") + "?mode=ro"
writer-lock 观测为 positive-only:非阻塞读取 .coordination.lock 协调文件,持锁只证明快照时有进程占用 Codex 规范线程锁,不识别进程也不证明活性。
A held lock proves only that some process owns the advisory lock; it does not
输入对账(reconcile_codex_inputs.py):用既有 ledger + 严格 lineage reader 组合出整会话原始输入计数与引文,保留 occurrence/原文/来源坐标;exit 2 或 complete:false 视为不完整,scope_input_count: null ≠ 0。
Use the reconciler to compose the existing ledger and strict lineage readers. It preserves occurrences, original strings, and source coordinates.
超大 briefing 的上下文纪律:完整简报超模型上下文时先物化一次到私有临时文件并记录 SHA-256+行数,按标题/坐标读有界区间,未读区间一律报为 gap,禁止分片重跑拼出『完整』假象。
materialize it once to a private temporary file and record its SHA-256 plus line count before reading
2核心能力
3外部依赖
| 类型 | 依赖 |
|---|---|
| cli | git(工作区状态上下文,read_codex_session 中 subprocess) |
| cli | rg/grep(text.py 可选路径预过滤,与 claude 版共享 core) |
4风险提醒 风险提醒:蓝色 · 知晓即可
- 数据面=Codex 全量历史(可能含凭据粘贴与私密上下文) — 无凭证主动读取,但 ledger/rollout 内容本身敏感;SKILL 用『不 share、只读、gap 诚实』约束,均非技术强制。
- compaction/fork 记录的误导风险 — 压缩摘要与继承历史若被当逐字事实会错;依赖 agent 遵守身份/血统门禁流程。
- 大 briefing 临时文件残留 — 物化 temp 后若 agent 未清理会留含摘要文件;路径为私有 temp 但依赖 agent 行为。
5第二遍独立确认
- [ok] sqlite 只读强制 — _core/codex.py: sqlite_uri 加 ?mode=ro;inspect/collect 均 PRAGMA query_only=ON。
- [ok] 无任何网络外发 — 全 scripts 目录扫描无 requests/urllib/socket/curl/wget;本 skill 不含 history_index 类下载器。
- [ok] 凭证读取检查 — 全目录无 auth.json/API key/.env/密钥 env 访问;只读 rollout 与 ledger。
- [ok] SKILL 声明的 flag 与脚本存在性 — reconcile --through-record/--omit-first/--omit-last、list_codex_user_inputs --recent/--session-id/--per-session、analyze_sessions search --codex-only、read_codex_session --full 均核对到 argparse。
- [unlocatable] rollout 格式跨版本声明(0.142.2–0.149.0) — codex_rollout_format.md 自述 'Verified against ~2,600 real rollouts';源码内无法复核该实测声明,未运行 Codex 验证。
- [ok] writer-lock 观测语义 — list_local_history.py 251-283 非阻塞取协调锁 + 输出 positive-only 语义字符串,与 SKILL 描述一致。
6结论
c30dd57b4165452f…d5c4678cb5