Skip to content

fix: pipeline/extract.py could not read a Codex rollout transcript, so a Codex session saved zero memory (#443) - #449

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/443
Aug 29, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/443

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Summary

pipeline/extract.py only recognised Claude Code's transcript envelope
({"type": "user"|"assistant", "message": {...}}), so a real Codex session --
hooks firing, .remember/ created, one real human prompt and one real
assistant reply on the wire -- extracted 0 exchanges and saved nothing,
with no signal to the user that anything had gone wrong.

Closes #443

What changed

  • pipeline/host.py gained sniff_envelope() (identifies which host wrote a
    transcript line, from its shape -- "claude-code", "codex", or
    "unrecognised") and codex_exchange() (extracts (role, text) from
    Codex's event_msg/item_completed lines -- Codex's own record of what a
    human sent and what the agent's final answer was -- deliberately not from
    the same text's duplicate under response_item role: "user"/"assistant",
    which also covers session scaffolding: skill instructions, the
    recommended-plugins list, this plugin's own REMEMBER buffer preamble).
  • pipeline/extract.py gained sniff_file_envelope() (sniffs from the
    file's own first parseable line, independent of any resume position) and
    threads an envelope parameter through extract_messages() /
    extract_session(). ExtractResult gained an envelope field.
  • pipeline/shell.py and scripts/save-session.sh surface "unrecognised"
    as a distinct log line -- not folded into the same "0 exchanges" wording a
    genuinely quiet session gets, which is the exact silent failure this issue
    exists to prevent.
  • A trimmed, sanitised capture of the reproducing session is committed as
    tests/fixtures/codex-rollout.jsonl.
  • README.md's Codex section rewritten from "scaffolding, not yet verified"
    to name what is now observed against a live codex-cli 0.150.1 install
    (marketplace discovery, plugin install, three hooks firing, Read cwd and transcript_path from hook stdin instead of deriving them #407's
    session-id keying, resolve-paths.sh cannot resolve a project root on any host that does not set CLAUDE_PROJECT_DIR #411's cwd fallback) and what is still open (user-prompt and post-tool hooks cannot resolve the project root on Codex, so per-turn capture silently no-ops #444, a
    separate lane, referenced but not touched here).
  • changelog.d/443.fixed.md added, passes python3 .oss/assemble_changelog.py --check.

Self-review follow-up (second commit)

Spawned an Explore reviewer and the oss:auditor against the first commit.
Findings and dispositions:

  • Fixed: main()'s --json branch never carried the new envelope
    field into its output, so python3 -m pipeline.extract --json -- a
    documented, trusted-by-design entry point -- still could not distinguish a
    genuinely quiet session from an unparseable one. Added, with a red/green test.
  • Fixed: the "positive control" scaffolding-exclusion test asserted only
    that scaffolding text was absent from the output, which would pass
    identically if extraction produced nothing at all. Now also asserts the
    scaffolding is present in the raw fixture, and pins the exact surviving messages.
  • Fixed: pipeline/extract.py's module docstring still said "Claude Code
    session JSONL files" only.
  • Below the bar to fix or file: codex_exchange() counts every
    event_msg/item_completed line naming a UserMessage or AgentMessage
    unconditionally, with no per-turn de-duplication guard. If a future Codex
    release ever emits more than one item_completed per logical turn (a
    partial phase plus a final one, say), exchanges would double-count. There
    is no evidence in the fixture, the code, or the issue body that Codex
    actually does this -- the single captured session shows exactly one of
    each -- so this is a reachable-in-theory, not reachable-in-practice, class
    argued down rather than filed.

Deliberately not fixed here (separate filing)

scripts/save-session.sh already advanced the saved read-position past
lines it could not successfully read (corrupt JSON, and now also an
unrecognised envelope) whenever EXCHANGE_COUNT is 0 -- a pre-existing,
general defect, not specific to Codex (the issue's own "position -> 15"
note flags it). Left alone; see the report for the filing detail.

Test plan

  • tests/test_extract.py -- new tests red before the fix (AttributeError
    on ExtractResult.envelope, missing sniff_envelope), green after.
  • tests/test_shell.py, tests/test_save_session_gates.py -- new tests
    for the ENVELOPE shell-bridge variable and the distinct log line.
  • Full suite (pytest): 1815 passed, 43 skipped, 91.21% coverage.
  • python3 .oss/assemble_changelog.py --check: ok.

fdaviddpt and others added 2 commits August 29, 2026 07:43
… Codex session silently saved zero memory (#443)

Codex writes {"timestamp", "ordinal", "type", "payload"} lines, with role
and text one level inside `payload`; extract.py only knew Claude Code's
{"type": "user"|"assistant", "message": {...}} shape. A real Codex session
-- hooks firing, .remember/ created, a real prompt and reply -- extracted
0 exchanges, indistinguishable from a genuinely quiet one.

pipeline/host.py now sniffs a transcript's envelope from its own first
line and reads either shape; an envelope matching neither is reported as
"unrecognised" (ExtractResult.envelope, surfaced to save-session.sh's log)
rather than silently counted as zero. A trimmed, sanitised capture of the
reproducing session is committed as tests/fixtures/codex-rollout.jsonl.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…st, refresh a stale docstring

Self-review (Explore + oss:auditor) on the #443 commit found three real
issues, addressed here:

- pipeline/extract.py's `main()` --json branch built its dict from
  ExtractResult by hand and never picked up the new `envelope` field, so
  `python3 -m pipeline.extract --json` -- a documented, trusted-by-design
  entry point -- still could not tell a genuinely quiet session from one
  whose transcript this module could not parse at all. Added, with a
  red/green test (test_main_json_flag).
- test_extract_messages_codex_rollout_positive_control_scaffolding_excluded
  asserted only that scaffolding text was ABSENT from the extracted output;
  it would have passed identically if extraction produced nothing at all.
  Now asserts the scaffolding IS present in the raw fixture (so trimming
  the fixture down would fail loud) and pins the exact two surviving
  messages.
- pipeline/extract.py's module docstring still said "Claude Code session
  JSONL files" only; it now names both envelopes and points at
  sniff_file_envelope()/pipeline/host.py.

A third finding (codex_exchange() has no per-turn de-duplication guard
against a hypothetical future Codex emission of multiple item_completed
events per logical turn) is below the bar to fix or file: no evidence in
the fixture, the code, or the issue body that Codex actually does this --
reported in the PR body rather than acted on.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@fdaviddpt
fdaviddpt merged commit 3c0ff9d into main Aug 29, 2026
13 checks passed
@fdaviddpt
fdaviddpt deleted the fix/443 branch August 29, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

extract.py cannot read a Codex rollout transcript, so a Codex session silently saves zero memory

1 participant