The alembic cartridge
The distillation layer is named alembic. It knows how to load Codex, Claude, Gemini, and OpenCode session formats, strip them to the portable conversation, and materialize the target runtime's native session.
The pipeline
source session file
-> load (codex / claude / gemini / opencode reader)
-> neutral IR [ {role, text}, ... ]
-> sanitize (drop scaffold, redact secrets; tools opt-in, reasoning never)
-> record snapshot (~/.constant/snapshots/…, written FIRST)
-> target native session file (codex / claude / opencode writer)
-> native resume (codex resume <id> / claude -r <id> / opencode -s <id>)It is hub-and-spoke through a neutral intermediate model, never pairwise converters — each runtime needs one codec, not one per neighbor. The payload (text, role, timestamp) rides through almost untouched; the envelope and the threading are the real work, because that is where the runtimes differ. Every distillation produces a receipt of what crossed.
Native resume is strict
Writing the file is not enough; the target's loader must accept it. Constant matches each runtime's native schema exactly, down to the installed version string, so the session resumes as the runtime's own scrollback. Miss a field and the runtime rejects the whole file. All session and registry writes are atomic (write a tmp sibling, fsync, rename), so a crash mid-switch can never destroy the newest turns.
OpenCode is the exception that proves the rule: instead of writing its store
directly, Constant goes through opencode's own supported door — export-shaped
JSON handed to opencode import, which validates it, preserves the session id,
and upserts on refresh.
Stable projections, no proliferation
Each logical conversation gets a stable set of Constant-owned projections, one
per runtime. A switch reuses and overwrites its own projection for the target,
rather than minting a new file each time, so ping-ponging keeps exactly one
projection per runtime, kept in sync and visible in each CLI's own /resume
under the conversation's name and handle.
Your original sessions are read as the seed but never written, and the distilled IR is snapshotted to the record before any native write. See the Trust boundary.
Prior art
The low-level format codecs and the neutral IR are vendored from transession (MIT, Yiming Zhang). Constant adds the sanitize/redact distillation, native-resume hardening, stable projections, trail naming, and the live host.