Skip to main content

Module codex

Module codex 

Source
Expand description

Codex HarnessAdapter — Rust port of packages/cli/src/harnesses/codex.ts.

Codex shares the pending-stamp + watch-loop shape with OpenCode, so the adapter is constructed via super::pending_stamp::adapter_static instead of re-implementing the trait. The only codex-specific bits are:

  • name = "codex" — the dispatch key and log-line label.
  • session_root$HOME/.codex/sessions, resolved lazily so tests that override $HOME see the override.
  • ingest_sessions — opens a fresh ledger handle and runs relayburn_sdk::ingest_codex_sessions (the codex-only ingest pass). The TS sibling calls ingestCodexSessions() directly here; the Rust SDK function takes &mut Ledger, so the closure opens a handle each call. That mirrors the TS lock-then-write-then-close shape, and the per-tick open is cheap (SQLite WAL, no DDL after first open).

The factory’s super::pending_stamp::adapter_static does the Box::leak so the registry can store the result as &'static dyn HarnessAdapter. See the factory module for the leak rationale (codex/opencode are the only two callers; runtime cost is a few dozen bytes per process).

Functions§

adapter
Convenience: hand out a &'static dyn HarnessAdapter for the codex adapter. The registry calls this once at lazy-init time. See pending_stamp::adapter_static for the leak semantics — codex is one of two callers and the leaked footprint is bytes, not megabytes.
config
Build the PendingStampAdapter config for codex. Exposed as a constructor function (rather than a static) because the closure captures and the Arc<dyn Fn>s inside don’t fit a const initializer. The registry calls this once and feeds the result to pending_stamp::adapter_static.