[codex] canonicalize gateway transcript storage#10560
Open
g-guthrie wants to merge 11 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
This PR removes duplicate gateway transcript persistence paths and makes
gateway/session.pythe single owner of transcript storage behavior.Specifically:
gateway/mirror.pynow routes transcript writes through the canonical session helpers instead of maintaining its own JSONL and SQLite write logic.session_metapayloads now survive the canonical SQLite transcript path instead of being flattened away.Why it changed
The gateway had multiple independent ways to persist the same transcript data:
SessionStoregateway/mirror.pygateway/session.pyThat split ownership increased drift risk and bug surface in one of the most state-sensitive parts of the gateway.
User and developer impact
Gateway session history now has one canonical persistence path when SQLite is available. That makes transcript behavior easier to reason about and reduces the chance that mirrored messages or resumed sessions diverge from normal session behavior.
For older sessions, legacy JSONL history is imported into SQLite only when it can be merged safely. If the histories diverge ambiguously, the code leaves the JSONL transcript in place rather than risking data loss.
The canonical SQLite path also now preserves transcript-only
session_metapayloads, so the replacement backend is closer to the behavior of the legacy JSONL transcript.Root cause
Transcript persistence had grown into a multi-path design where JSONL stopped being just a migration shim and effectively became a second live backend. That forced reconciliation logic, duplicate writes, and sidecar behavior outside the main session store.
Validation
Focused validation passed:
source venv/bin/activate && venv/bin/python -m pytest -o addopts='' tests/gateway/test_session.py tests/gateway/test_mirror.py tests/run_agent/test_860_dedup.py -qsource venv/bin/activate && venv/bin/python -m pytest -o addopts='' tests/gateway/test_retry_replacement.py tests/gateway/test_session_dm_thread_seeding.py tests/run_agent/test_session_meta_filtering.py -q