1仕組みと動作原理
互いに代替不可能な Codex の3つの履歴サーフェス(history.jsonl: prompt ledger・ユーザー送信原文、state_*.sqlite: マニフェストメタデータ、sessions|archived_sessions 配下の rollout-*.jsonl: 完全なイベントストリーム)を読み込み、各クエリを専用スクリプトにルーティングし、場当たり的な再結合(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 を設定します。スキーマの互換性がない場合は生の rollout JSONL スキャンへフォールバックします。
return "file:" + quote(path.resolve().as_posix(), safe="/:@") + "?mode=ro"
writer-lock の観測はポジティブオンリー(陽性のみ): .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.
大容量ブリーフィングに対するコンテキスト規律: 完全なブリーフィングがモデルのコンテキスト制限を超える場合、まずプライベートな一時ファイルに一度実体化して SHA-256 と行数を記録します。見出しや座標に基づいて有界な区間のみを読み、未読区間はすべてギャップとして報告し、断片的な再実行による「完全」な外観の偽装を禁止します。
materialize it once to a private temporary file and record its SHA-256 plus line count before reading
2コア機能
3外部依存関係
| Kind | Dependency / Endpoint |
|---|---|
| cli | git(工作区状态上下文,read_codex_session 中 subprocess) |
| cli | rg/grep(text.py 可选路径预过滤,与 claude 版共享 core) |
4推奨統制措置と判定根拠
- scripts/: ローカルスクリプトまたはコマンドの実行: python3 による同梱の5つのスクリプト実行(純粋な標準ライブラリのみ)
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…