17/813205bbce/ has two sessions: 0/ = Codex (agent: "Codex", model gpt-5.4, session 019dba89…), 1/ = Claude Code (agent: "Claude Code", 10 checkpoints, 737-line transcript).
Codex's 0/ contains only metadata.json — no full.jsonl, no prompt.txt, no content_hash.txt. Top-level sessions[0].prompt is even explicitly "".
So Codex was a first-class session. It was registered and condensed — just with nothing to condense.
Why 0/ is empty
The session-state file .git/entire-sessions/019dba89-44d8-79f1-8151-b605e6a3c7d2.json gives it away:
"phase": "active",
"checkpoint_count": 0,
"last_prompt": " You are Codex performing an adversarial software review..."
checkpoint_count: 0 — no SaveStep ever fired for this Codex turn. The shadow branch never got .entire/metadata/019dba89…/full.jsonl or prompt.txt written to it.
phase: "active" — the session never transitioned to idle/ended. Stop hook never cleanly closed it.
Yet base_commit, last_prompt, and agent/model fields are populated, so something wired Codex into Entire at session start, just not at turn end.
What condensation did
At commit time, condenseSessions walks session-state files and writes a /metadata.json per session — that's why 0/metadata.json exists (and carries agent_lines: 0, agent_removed: 228, human_removed: 849 — those come from a base_commit
→ HEAD diff, not from the transcript). When it went to copy transcript files from .entire/metadata/019dba89…/ on the shadow branch, that dir was empty, so full.jsonl / prompt.txt / content_hash.txt simply weren't produced.
The prompt.txt miss is particularly telling: last_prompt is right there in session state, but the checkpoint dir gets its prompt from shadow-branch prompt.txt, not from session state.
Root cause
This is a bug in the Codex agent integration (still IsPreview: true in cmd/entire/cli/agent/codex/codex.go:51). When /codex:adversarial-review runs Codex:
Something creates the Entire session state — likely Codex's SessionStart/init hook, which stores last_prompt and agent_type: "Codex".
Codex does its review work and exits.
The per-turn snapshot path that should write .entire/metadata//full.jsonl + prompt.txt on the shadow branch (via SaveStep) never runs — either because the Stop hook doesn't fire in the subagent flow, or because the
rollout-to-metadata copy step is missing/short-circuiting.
Claude Code's own turn completes normally (1/ gets the full treatment).
User commits → condensation → Claude Code's session is fully copied; Codex's session contributes only the metadata.json stub.
If you want real Codex transcripts in future checkpoints, the fix is in the Codex agent wiring — probably its Stop-equivalent handler needs to read ~/.codex/sessions/YYYY/MM/DD/rollout-*-019dba89….jsonl and persist a snippet into the
shadow branch's .entire/metadata//full.jsonl (and prompt.txt) the way Claude Code does.
If you need to look at a commit / checkpoint look at commit be7ff386a38c354805957294833a43f816267f5f in ../entiredb
Now I want us to focus on two things:
can we prevent this happening at all, like why are we writing 0/metadata.json and there is no session log, we should not do this at all. There should never be a session without a session log, can we hard guard this somewhere? Or is this needed since the log might come later?
can we figure out a way to handle this better and/or debug why the codex subsession hooks are not firing?
Assistant
Let me check a couple more things quickly.
Assistant
OK, I have enough to answer. Let me confirm one last piece — whether redaction can silently drop the transcript while still letting metadata.json be written.
Assistant
Found the actual mechanism. Here's what's going on and what I'd recommend:
Why 0/metadata.json exists with no transcript
The skip gate at manual_commit_condensation.go:165 does exist (added 2026-04-14), but there's a second path to the stub right after it. Line 182-191:
go
redactedTranscript, redactDuration, err := redactSessionTranscript(ctx, sessionData.Transcript)
if err != nil {
logging.Warn(logCtx, "failed to redact transcript secrets, dropping transcript for checkpoint", ...)
redactedTranscript = redact.RedactedBytes{} // transcript dropped
}
// ... continues to write metadata with empty transcript ...
So the most likely sequence for be7ff386's Codex session:
state.TranscriptPath was set (SessionStart fired) → rollout file was readable
extractSessionData populated sessionData.Transcript from the live rollout
Skip gate at line 165 passes (Transcript non-zero)
filterFilesTouched populates FilesTouched with all 17 committed files via the mid-turn fallback (since state.FilesTouched is empty — no SaveStep)
redactSessionJSONLBytes errors on some line in the Codex rollout → transcript silently dropped
writeTranscript sees empty bytes → skips full.jsonl + content_hash.txt (committed.go:668-670)
writeSessionToSubdirectory writes metadata.json anyway with the 17 fallback files_touched
The agent_lines: 0 / agent_removed: 228 / human_removed: 849 attribution matches this too — no shadow-tree entries for Codex means attribution sees zero agent work against the committed diff.
Q1: Hard guard — what I'd recommend
The right guard isn't a single check; two small changes would cover it:
Don't write metadata.json when there's no transcript AND no SaveStep ran. In CondenseSession, after the redaction fallback, add: if redactedTranscript.Len() == 0 && state.StepCount == 0 && !hasShadowBranch, return Skipped: true. The existing skip gate explicitly gates "genuinely empty" sessions based on extracted data; this one gates "lost during redaction" sessions based on raw state. Tradeoff: you lose the "file touched but no transcript" diagnostic trail; but that trail is mostly junk today (it claims files for a session that never ran SaveStep).
User
can you maybe validate, the codex source is here: /Users/soph/Work/entire/research/codex
Assistant
Validated. Here's what I found in the Codex source:
Stop hook firing — confirmed mechanism
codex-rs/core/src/session/turn.rs:537 — Stop hook fires inside the turn loop, awaited before break:
rust
let stop_outcome = sess.hooks().run_stop(stop_request).await;
// ...
if stop_outcome.should_stop { break; }
Both interactive and codex exec use this same path (exec just wraps it and exits on TurnCompleted). So in normal operation, Stop does fire.
Where it's skipped
turn.rs:626-655 — Stop is skipped entirely on these exit paths:
All of these break straight out of the loop without firing Stop. No cleanup hook. This matches the symptom exactly: SessionStart and UserPromptSubmit fired (early in the turn), Stop didn't (because the turn ended on an error path).
/codex:adversarial-review — one surprise
I went looking for this and it's not using Codex's built-in guardian review mode. It's an Entire trail runner (.entire/runners/trail-security.json on Andrea's side) — and that specific runner actually invokes claude -p, not Codex at all. So there's a separate slash command somewhere (probably a user/shared Claude Code command) that shells out to codex exec "..." with the adversarial prompt. Either way, the invocation goes through the same turn loop, so the error-path skip applies.
Worth noting: codex-rs/core/src/guardian/review_session.rs:873-894 explicitly disablesFeature::CodexHooks for Codex's internal guardian sub-agents. Not relevant here (the session state shows hooks did fire, so the flag was enabled), but good to know — if anyone ever invokes a Codex guardian review through Entire, no hooks will fire at all. Not just Stop — nothing.
Sharpened recommendations for Q2
Given the error-path skip is real and documented in the Codex source:
Add a rollout-based reconciliation on condense. We already resolve the rollout file via TranscriptPath. If Codex's session is ACTIVE at condense time and the rollout's last line has a / marker (or just a much-later mtime than the session state's ), treat it as an implicit Stop: read the rollout, run the SaveStep-equivalent in condense, then flip phase to IDLE. This closes the gap without needing Codex to fix anything upstream.
User
is it worth filing this as a bug with codex?
Assistant
Yes, but narrow it — don't file "Stop hook doesn't fire" (they'll reasonably say "it fires on normal turn completion, working as designed"). File it as "No hook notification when a turn terminates via an error path" with a concrete repro.
The specific ask that's hard to wave away: at turn.rs:626-655, three error branches break without firing Stop or any replacement event. Downstream integrations have no signal that the session is done. Either (a) fire Stop with an error/aborted status field, or (b) add a separate SessionEnd/TurnFailed hook, or (c) document it clearly so integrators know they need a fallback.
Arguments for filing:
The Codex hooks feature is still default_enabled: false / "UnderDevelopment" per your AGENT.md — this is exactly the phase where reporting gaps is welcome.
Their own AGENT.md already flags "No SessionEnd hook" as a known gap. Your bug sharpens that from "no clean-session-termination hook" to "no any-termination hook when the turn fails". Probably on their radar already; you'd be adding a concrete case.
The CodexHooks-disabled-for-guardian-review behavior is worth mentioning too — arguably a separate bug (hooks silently no-op instead of producing a startup warning), but same filing if you bundle them.
Arguments against / why not urgent:
Our rollout-reconciliation workaround doesn't need them to fix anything.
Their turnaround on integration bugs is unknown.
I'd write it up in ~10 minutes: the two code pointers above, a one-paragraph repro (force an error mid-turn), and the three options as the ask. Worth it — even if they don't fix it soon, you get a linkable issue to reference in our AGENT.md and future debugging.
User
when a turn terminates via an error path
why are we assuming error path?
Assistant
Fair pushback — I over-committed. The only hard evidence we have is:
SessionStart + UserPromptSubmit fired (session state has agent, model, last_prompt)
SaveStep never ran (checkpoint_count: 0, no transcript on shadow branch)
Phase stayed active (never flipped to IDLE)
That's consistent with "Stop never fired", but it's also consistent with several other failure modes I didn't distinguish:
Stop fired, handler crashed before SaveStep.handleLifecycleTurnEnd in lifecycle.go:279-404 has multiple early-return error paths before the SaveStep call — transcript file missing at line 320, ReadTranscript fails at 350, write fails at 357. Any of these returns an error and the hook exits non-zero, leaving state in the exact shape we see.
Hook timed out. Codex's hooks.json has "timeout": 30. If SaveStep's git operations (building a shadow commit) exceed 30s — not impossible on a large tree — Codex kills the subprocess mid-flight.
Race with PostCommit. User committed while Codex was mid-turn or while Stop was still running. PostCommit fires first, condensation sees the incomplete state, writes the stub. (Less likely but the ACTIVE phase would look identical either way.)
codex exec specifics I didn't fully trace. I showed turn.rs:537 fires Stop, but didn't verify exec doesn't short-circuit anywhere. Worth re-checking.
The error path — still possible, but I was asserting it as the likely cause with no actual signal pointing there over the others.
So: filing a bug right now is premature. The right move is the instrumentation I suggested (append to .entire/logs/codex-lifecycle.log from each hook) — next repro tells us which of these five it actually is. If it's #1 or #2, the fix is entirely on our side. If it's really a Stop-never-fired case (whether error-path or exec-specific), then file with the evidence in hand.
Want me to add the instrumentation as a small PR so we catch the next occurrence?
User
/copy
copy
User
I chatted with the reporter again, we were wondering if maybe ctrl+c was used, but here is the analysi:
:black_circle_for_record: Short answer: no evidence you hit ctrl-C on the Claude Code session itself. The Codex side is suspicious, but the fingerprint points more at missing integration than at an interrupt.
What the artifacts say:
Claude Code (28c2a1e4) — clean run:
- 865 transcript lines spanning 13:05:23Z → 14:47:17Z (1h42m)
- Stop reasons: 337 tool_use, 24 end_turn, 1 stop_sequence — no "interrupted":true, no SIGINT/SIGTERM/abort markers
- 11 turns, 10 checkpoints, condensed normally at commit time (14:09Z)
- Only 2 BashOutput reads across 3 /codex:adversarial-review launches — you fired them and barely looked at them, but CC itself finished naturally
All three: phase: "active", checkpoint_count: 0, last_interaction_time literally microseconds after started_at. That means Codex's SessionStart-equivalent fired once to register the session, and then no other Entire hook ever ran for
those sessions. No UserPromptSubmit, no Stop, no PostCommit.
And no rollout files exist at all — ~/.codex/sessions/2026/04/23/ doesn't exist (dir jumps 22 → 01/01 the other way). That's true for all three launches, not just one.
Why this isn't a ctrl-C story:
If you'd ctrl-C'd the CC session, the CC transcript would typically show an abort marker and you'd expect only later codex subprocesses to die; the first one (12:56Z) had 1h50m to run before CC exited. Three identical microsecond-gap
start/stop windows in three different sessions is a systematic pattern, not a one-off interrupt.
The more likely story: Codex's Entire integration (still IsPreview: true) registers a session at launch but its turn-end handler — the one that's supposed to read ~/.codex/sessions/.../rollout-*.jsonl and write snippets into
.entire/metadata//full.jsonl on the shadow branch — isn't running, at least not in the codex-companion.mjs subprocess path used by /codex:adversarial-review. That also explains why no rollout files exist at all for that
day: the companion likely runs Codex with some output-capture mode (or a different CODEX_HOME) that bypasses the normal session directory, so neither Codex's own rollout nor Entire's mirror of it ever lands on disk.
If you want to be extra sure it wasn't ctrl-C: check your shell history for that window — ctrl-C in CC often leaves a partial command line on disk — and see if /codex:status on 2026-04-23 reported completions.
Assistant
That's a much better signal than anything we had before. The microsecond gap across three independent launches kills all my earlier hypotheses — this isn't an error path, a timeout, a race, or a handler crash. Those would each produce different fingerprints and wouldn't repeat identically three times.
The "no rollout files exist at all" is the key clue. Let me check one thing I glossed over earlier.
Assistant
This is the cleaner story now. I think you can retire the error-path theory. The microsecond fingerprint, multiplied across three launches, plus no rollout files on disk at all, maps precisely onto one specific bug on our side, not Codex's.
The fingerprint tells us Stop probably did fire — we just rejected it
manual_commit_session.go:321-322 sets StartedAt and LastInteractionTime to the same now when a session is created (the brand-new-session branch of InitializeSession). Then the EventTurnStart transition at phase.go:157-160 emits ActionUpdateLastInteraction, which overwrites LastInteractionTime with a fresh time.Now() ~1-3ms later. So a 1ms gap is exactly what a normal SessionStart+UserPromptSubmit flow produces — nothing is frozen about it, the session was fully initialized.
What didn't happen after that: no further TurnStart, no Stop-side update, no PostCommit-side phase transition visible in state.
Now — no rollout files at all strongly suggests Codex was invoked with transcript_path: null (the --ephemeral mode flagged in Codex's own AGENT.md:174, 199). Under that mode Codex still fires all three hooks, just with null transcript paths. And here's the relevant line in our code — lifecycle.go:322-324:
go
transcriptRef := event.SessionRef
if transcriptRef == "" {
return errors.New("transcript file not specified")
}
Turn-start doesn't enforce this (it proceeds and stores TranscriptPath=""), but turn-end bails immediately with a non-zero exit. So Codex's Stop hook fires, our handler rejects it, Codex logs a hook failure, and the session is stuck in ACTIVE forever — checkpoint_count: 0, no SaveStep, no rollout, no transcript.
Three launches → three identical stubs. No error path in Codex needed.
Revised take on whether to file
Not really. This isn't a Codex bug — null transcript_path in ephemeral mode is documented behavior. The bug is ours: we accept ephemeral sessions on the way in and reject them on the way out. Two realistic fixes on our side:
Refuse ephemeral sessions at SessionStart. If transcript_path is null, don't register the session at all; log a warning that ephemeral Codex runs aren't supported. Clean, no stub checkpoints, but the user loses any hope of capturing those turns.
User
ok, one more data point: it seems using /codex:adversarial-review can timeout, that would be one of the cases where there is no stop hook?
Assistant
Yes — that's the cleanest fit yet. Timeout that ends in a SIGKILL/SIGTERM of the Codex subprocess maps straight onto one of the no-Stop paths I flagged earlier from turn.rs:626-655 (or actually, one worse than those: the process is terminated before it even reaches the error branch). No Stop hook, full stop.
A few things this reframes:
The microsecond fingerprint still fits. Remember what the 1-3ms delta actually measures: the gap between initializeSession setting StartedAt (manual_commit_session.go:321) and the EventTurnStart transition emitting ActionUpdateLastInteraction (phase.go:157-160). Both run inside a single UserPromptSubmit hook invocation. After that, whether Codex ran for 1 second or 10 minutes before being killed, LastInteractionTime doesn't move — nothing updates it until a subsequent hook fires, and if timeout→SIGKILL, none does. So the fingerprint doesn't tell us the session ran for microseconds; it tells us nothing happened after UserPromptSubmit returned. Timeout is as consistent with that as ephemeral was.
But the "no rollout files at all" clue cuts against pure timeout. Codex writes to the rollout line-by-line as events happen — not buffered until shutdown. A timeout-killed Codex mid-turn should leave a partial rollout on disk at ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl. The reporter says the entire day's directory is missing. So either:
The companion is setting a different CODEX_HOME (temp dir, gets cleaned up), and enforces a timeout — both matter
Codex is invoked with --ephemeraland gets killed by timeout (ephemeral explains no rollout, timeout explains no Stop — either alone would also work here, and you'd get this combined picture)
Or some combination we don't have visibility into until someone reads codex-companion.mjs
Revised filing/fix recommendation. If timeout is the dominant pattern, what you want from Codex is the same ask I suggested earlier but with a better repro: "when the Codex process is terminated externally (SIGTERM) during a turn, there's no cleanup hook — downstream integrations have no way to know the session ended. Would be useful to (a) install a SIGTERM handler that fires Stop with an interrupted status, or (b) expose a SessionEnd hook that fires unconditionally on process exit." That's a concrete, testable ask they can say yes or no to.
On our side, the rollout-reconciliation fallback I suggested before becomes the primary fix regardless: at condense time, for ACTIVE external-agent sessions with a known TranscriptPath, read the rollout (if present), extract what we can, and finalize the session. That covers both "Codex crashed" and "Codex was killed by timeout" without needing upstream changes.
User
but more data:
[codex] Running command: /bin/zsh -lc "nl -ba cmd/worker/syncer.go | sed -n '60,140p'"
[codex] Command completed: /bin/zsh -lc "nl -ba cmd/worker/syncer.go | sed -n '60,140p'" (exit 0)
[codex] Running command: /bin/zsh -lc "nl -ba cmd/worker/syncer_test.go | sed -n '220,360p'"
[codex] Command completed: /bin/zsh -lc "nl -ba cmd/worker/syncer_test.go | sed -n '220,360p'" (exit 0)
[codex] Assistant message captured: {"verdict":"needs-attention","summary":"No-ship: the new redirect auth logic relies on an uns...
[codex] Turn completed.
# Codex Adversarial Review
code
Target: working tree diff
Verdict: needs-attention
No-ship: the new redirect auth logic relies on an unsafe DNS heuristic, so it can leak the mirror key to a broader host set and still fail on valid cluster topologies.
Findings:
- [high] Cluster membership is inferred with a brittle suffix heuristic that widens the trust boundary and misses some legitimate sibling redirects (cmd/worker/syncer.go:90-126)
`clusterFQDN` strips the first label from any 4+ label target host, and `hostInCluster` then treats any hostname ending in `.`+cluster as trusted. That is not equivalent to 'the configured cluster and its direct replicas'. For
example, a 4-label cluster entry host like `mirror.prod.example.com` is broadened to `prod.example.com`, so redirects to unrelated siblings under that parent zone would receive `X-Entire-Mirror-Key`. The opposite failure also
exists: a node-specific 3-label host like `node1.cluster.local` is left unchanged, so a redirect to `node2.cluster.local` still drops auth and reproduces the original 401. This is an inference from the code plus the documented
`ENTIRE_TARGET_URL` contract: the config does not constrain hostnames to the one shape this heuristic assumes. The result is a silent trust-boundary regression in some deployments and a silent auth regression in others.
Recommendation: Do not derive cluster identity from label count. Pass the authoritative cluster FQDN explicitly, or reuse the server/discovery implementation that defines valid same-cluster hosts. If matching remains local,
restrict it to the exact cluster host or exactly one replica label, and add tests for 3-label node hosts, 4-label cluster entry domains, and deeper subdomains.
Next steps:
- Replace `clusterFQDN`/`hostInCluster` with an explicit cluster host matcher from authoritative config or shared discovery code.
- Add regression tests covering nested subdomains, 3-label node hostnames, and 4+-label cluster entry domains before shipping this redirect behavior.
Assistant
Yes — this is the killing blow for the earlier theories. The log sequence tells us exactly what happened:
code
[codex] Turn completed. ← Codex's internal turn loop finished
# Codex Adversarial Review ← final message streamed to stdout
...
⎿ (timeout 10m) ← Claude Code's Bash tool fired SIGKILL
Codex reached turn completion, which means control reached turn.rs:537 and Stop was dispatched (that line fires before the break; that leads to "Turn completed"). So the Stop hook was invoked. It just never had a chance to finish.
Why the state still looks post-TurnStart-only
Look at the order of operations in lifecycle.go:handleLifecycleTurnEnd:
Check transcriptRef != "" (bail if empty)
PrepareTranscript / fileExists check
Create session dir, read transcript, copy to session dir
Load pre-prompt state, resolve offsets
Backfill prompt.txt
... detect file changes ...
SaveStep — this is where state.FilesTouched gets merged, shadow branch commit gets built
TransitionAndLog(EventTurnEnd) — only here does ActionUpdateLastInteraction fire and LastInteractionTime move
LastInteractionTime is only bumped at step 8. If SIGKILL hit anywhere from step 1 through step 7 — which is everything expensive: the transcript copy, the go-git shadow commit, the redact pass — you'd see exactly what the reporter found: checkpoint_count: 0, no shadow branch content, LastInteractionTime still at the TurnStart value from 10 minutes earlier.
What the 10m timeout actually kills
Claude Code's Bash tool timeout kills the entire process tree, not just Codex. That includes entire hooks codex stop, which is a child of the Codex process. Between Codex's Stop dispatch (.await on the hook subprocess) and the Bash tool's SIGKILL, you have however many milliseconds remain of the 10m. If the review turn itself took 9m30s, the Stop hook has ~30s, which is roughly the time a SaveStep of a multi-file shadow commit takes. It's easy to see this racing.
Implications
For filing with Codex: the ask gets cleaner again. "codex exec should install a SIGTERM handler that fires Stop (with or a new field) synchronously before exiting, so wrapper timeouts don't silently drop session-end notifications." That's a much smaller ask than a SessionEnd hook, and more likely to land.
User
can you also look at /Users/soph/Work/entire/research/codex-plugin-cc this is the plugin in use
Assistant
Got it — this is definitive. The smoking gun is in codex.mjs:
And the adversarial-review command routes through runAppServerTurn (codex-companion.mjs:408), which hits the ephemeral: true default.
So the plugin uses the Codex app-server protocol (not codex exec), and every adversarial-review thread is ephemeral by design. That's consistent with every piece of evidence we have:
No rollout files anywhere, not just for the failed sessions. Ephemeral threads don't write to ~/.codex/sessions/. Period. The missing directory isn't a clue about failure — it's the normal state for this command.
Three identical microsecond fingerprints. All three runs went through the same ephemeral path. SessionStart and UserPromptSubmit fired with transcript_path: null, our turn-start handler proceeded anyway, and Stop fired but hit our lifecycle.go:322-324 bail-on-empty-SessionRef guard.
The timeout is real but mostly incidental here. Even if the plugin had completed cleanly in 2 minutes, the session would still have been stuck ACTIVE, because ephemeral means no transcript to save.
What this means for the plan
Revised culprit ranking:
Ephemeral mode + our bail-on-empty-transcript — the primary bug. Ships every time adversarial-review runs.
10m Bash-tool timeout SIGKILL — real but only matters for runs that actually exceed the timeout; the ephemeral issue hits every run regardless.
Don't file with Codex. Ephemeral is documented, working-as-designed, and intentional — the whole point of the app-server protocol is to support short-lived review threads that don't pollute the user's session history. The plugin is also doing the right thing by making reviews ephemeral. The bug is entirely on our side.
User
/copy
copy
User
what part in this triggers the first hook then?
Assistant
Good question — let me actually check that, because I've been asserting hooks fire without verifying the app-server path specifically.
Assistant
Good catch — I was sloppy about this. The short answer: the Codex turn loop itself, not thread creation. Let me walk through the actual sequence because the details matter for the fix.
Where the first hook actually fires
turn.rs:301 — first line of the main turn function:
rust
if run_pending_session_start_hooks(&sess, &turn_context).await { return None; }
SessionStart fires lazily on the first turn, not when thread/start is called on the app-server. The RPC flow for the plugin is:
client.request("thread/start", ...) → Codex creates a Session object, marks pending_session_start_source = Some(...) (session/session.rs:945). No hooks yet.
client.request("review/start", ...) or turn/start → Codex enters turn.rs:279, calls run_pending_session_start_hooks → SessionStart fires here with transcript_path: null (ephemeral).
A few lines later at turn.rs:309, run_user_prompt_submit_hooks → UserPromptSubmit fires with transcript_path: null.
Normal turn loop runs.
At turn end, turn.rs:537 → Stop fires with transcript_path: null.
All three fire for ephemeral app-server threads. None is suppressed because of ephemeral: true. The only thing ephemeral changes is what sess.hook_transcript_path().await returns — and for ephemeral it returns null.
What matters for the fingerprint
Looking at our side (lifecycle.go:65-141), handleLifecycleSessionStartdoes not create session state. It just prints the banner, stores a model hint, and fires an EventSessionStart transition only if state already exists. For a fresh Codex thread, no state exists, so SessionStart is effectively a no-op for state creation.
handleLifecycleTurnStart (lifecycle.go:200) is where InitializeSession runs → which calls initializeSession (manual_commit_session.go:321-322) setting StartedAt and LastInteractionTime to the same . Then the transition bumps ~1ms later.
User
I'm fine with #2 if there is no session ref / file availble. The tool call is probably actually in the claude logs?
Assistant
Yes — the /codex:adversarial-review invocation goes through Claude Code's Bash tool, which means:
The outer Claude Code turn records the tool_use for node codex-companion.mjs adversarial-review ...
When the command completes (or times out), its stdout — the full review text — lands in the Claude Code transcript as a tool_result block
That's captured by Claude Code's normal Stop hook / SaveStep flow, into the shadow branch, into the checkpoint
So in the specific case of adversarial-review, the semantically valuable content (the review markdown, the verdict JSON) is already captured upstream in the Claude Code session. What gets lost when we drop the ephemeral Codex session are mostly operational details:
Codex's prompt (the big adversarial-review template — but that's the plugin's static template, not user input, so low value)
Codex's token usage / model (partial value, mostly for stats attribution)
Codex's turn ID / thread ID (ephemeral by design, no one will want to resume them)
Nothing of that list is unrecoverable from the parent Claude Code transcript, and most of it you wouldn't mine anyway.
That tips the balance — the partial-capture option becomes less compelling when you realize what we're capturing is largely duplicative. I'd now lean toward the simpler path:
In lifecycle.go around the InitializeSession call at line 266, skip the call entirely when event.SessionRef == "". Also have handleLifecycleTurnEnd continue to bail on empty SessionRef (already does). Net effect:
No session state created for ephemeral runs → no stuck-ACTIVE sessions
No stub metadata in checkpoints → Q1 guards become belt-and-suspenders (still worth keeping for other edge cases)
PostCommit sees only Claude Code's session → cleaner attribution
One log line at session-start ("skipping ephemeral Codex session — use Claude Code transcript for context") so nobody wonders where their Codex session went
Two caveats before committing to this:
Truncation. Claude Code's Bash tool caps stdout at ~30k chars by default. Adversarial-review output is normally well under that, but worth sanity-checking the three existing cases to see how big the tool_results actually got.
Non-plugin ephemeral. If someone ever invokes directly from a terminal (not via the plugin, not wrapped in a Claude Code tool call), refusing the session silently drops their data. That's probably a non-user though — the plugin is the mainstream path, and anyone manually passing is opting out of persistence by definition.
User
ok, yeah letzt do a first -> distinct PR, and then we do b+c in another
Assistant
Let me look for the tests first, then scope the work precisely.
Assistant
Let me look at the existing tests to understand the setup pattern.
Assistant
There's a dedicated condense_skip_test.go file. Let me read it to match the existing pattern.
Assistant
Now I understand the existing test patterns. Let me look at the redaction error path more carefully to confirm my understanding before implementing.
Assistant
Now I'll implement Guard #1 (post-redaction skip) and Guard #2 (narrow filterFilesTouched fallback).
Assistant
Now Guard #2 — narrow the filterFilesTouched fallback:
Assistant
Now let me check that filterFilesTouched isn't called from anywhere else that I'd need to update:
Assistant
Single call site, only updated. Let me move to tests now.
Assistant
I see redactSessionJSONLBytes is a package-level var (line 108) — that's the seam for testing the redaction-failure path. Let me look at one more existing test to understand the helper pattern, then write the new tests.
Assistant
Now I'll add the tests to condense_skip_test.go (it's the natural home).
Assistant
I need to add the errors and redact imports to the test file.
Assistant
Let me run the new tests to make sure they pass before doing the full check.
Assistant
The test is failing because Guard #2 sees the non-empty transcript as evidence and applies the fallback, which keeps FilesTouched non-empty so Guard #1 doesn't fire. I need to think about this more carefully.
The bug scenario is "a session got attributed files it didn't actually touch." That happens when there's no real evidence the session did work in the committed change. A non-empty transcript that exists is evidence the session ran something, but not evidence it modified the committed files. The only signal that genuinely indicates "this session has touched files in the past" is StepCount > 0.
Let me narrow Guard #2 to just StepCount > 0:
Assistant
Now I need to update my test — the transcript-only-evidence test no longer applies (transcript alone isn't evidence). I should drop that test and add one that verifies a transcript-only session doesn't trigger the fallback:
Assistant
Now my Guard #1 redaction-failure test should also work because the test session has StepCount=0 and the fallback won't fire. Let me re-run:
Assistant
All five new tests pass. Let me also make sure I haven't broken existing tests in the strategy package:
Assistant
The existing TestCondenseSession_FilesTouchedFallback_EmptyState codifies legitimate mid-turn commit behavior — Claude Code first turn, transcript readable, StepCount=0. The fallback should still fire there. My narrowing of Guard #2 was too aggressive.
Let me restore the "transcript OR StepCount" evidence rule (which preserves that test) and adjust my new test accordingly:
Assistant
Now I need to fix my test that depends on the previous rule. The transcript-only test was meant to prevent fallback; with the restored rule, transcript IS evidence, so the fallback fires. Let me restore the original positive test:
Assistant
Let me also re-verify my Guard #1 redaction-failure test still works — the test session has TranscriptPath set, transcript will be non-empty, so the fallback would apply (filling FilesTouched). That breaks Guard #1. Let me check:
Assistant
The redaction-failure scenario only triggers Guard #1 when the filter ALSO produces an empty FilesTouched. Let me redesign the test for the realistic Guard #1 scenario: a session whose tracked files don't overlap with this commit gets skipped post-redaction instead of producing a metadata-only stub:
Assistant
All targeted tests pass. Now let me run the full strategy package:
Assistant
All strategy tests pass. Let me update task status and run the full check:
Assistant
The added lines pushed CondenseSession over the maintainability index threshold. Let me extract the post-redaction skip into a helper:
Assistant
Now add those two helpers:
Assistant
Lint clean. Let me run the strategy tests once more to confirm the refactor didn't break anything:
Assistant
Now run the full check (test:ci):
Assistant
Test:ci passed (including the Vogon canary). Let me commit on the existing branch:
Assistant
The committed.go diff is a nolintlint cleanup from mise run fmt (unrelated to my changes, but the formatter touched it). I'll include it since the format pass produced it.
Assistant
Branch is at parity with main. Let me commit:
Assistant
Done. Branch soph/prevent-empty-sessions has commit df8129624 with both guards, the helper extraction, and five tests covering the new behavior. mise run check passed (fmt + lint + test:ci including Vogon canary).
Summary of what changed in manual_commit_condensation.go:
Added skipIfPostRedactionEmpty — second skip gate after redaction, fires when both transcript and FilesTouched ended up empty
Added redactOrDrop — extracted the redaction error-handling block so CondenseSession stays under the maintidx threshold
Modified filterFilesTouched to take *SessionState and gate the fallback on sessionHasEvidenceOfWork(sessionData, state) (transcript non-empty OR StepCount > 0)
TestFilterFilesTouched_AppliesFallbackWithTranscriptEvidence — transcript evidence (the Claude-Code-first-turn case)
TestFilterFilesTouched_SkipsFallbackWithoutEvidence — Codex-companion case (no false attribution)
TestFilterFilesTouched_IntersectsWhenFilesTouchedPopulated — populated case still intersects
Ready to start PR (b+c) — skip-InitializeSession-on-empty-SessionRef + the end-to-end test — whenever you want.
User
simplify
/simplify
Assistant
Now I'll launch all three review agents in parallel.
Assistant
Aggregating the findings — I'll fix six items, skip the rest:
Fixing:
Extract newSkippedResult helper to DRY the two skip-result constructions
Drop hasShadowBranch param from skipIfPostRedactionEmpty — only used for one log field, not load-bearing for the gate
Replace "line 165" references in test comments (will rot)
Trim multi-paragraph helper comments
Remove redundant inline comment in filterFilesTouched
Generalize "Codex companion" wording (keep Codex as concrete example but make clear it's agent-agnostic)
Skipping:
Test mocking helper: single use, not worth abstracting
sessionHasEvidenceOfWork inlining: the named helper IS the documentation — inlining loses that
Reuse findings (no real existing utilities to use)
Efficiency: nothing to fix
Assistant
Now apply the cleanup. First, extract the skip-result helper and DRY the pre-redaction site:
Assistant
Now update the helpers — drop hasShadowBranch from skipIfPostRedactionEmpty, trim comments, add newSkippedResult:
Assistant
Now trim filterFilesTouched — drop the redundant inline comment, generalize the function comment:
Assistant
Now fix the test comments — drop the "line 165" references:
Assistant
Now run fmt + lint + tests to verify nothing broke:
Assistant
The mise run fmt stripped nolint comments from committed.go (unrelated to my changes — formatter is overzealous). Let me restore those:
Assistant
The lint mode only reports issues for "files involved in current changes" — when I touched the strategy file, committed.go came along. The nolints were removed by fmt originally and the issue surfaces when any change is present. Let me restore the nolints:
Assistant
Lint clean. Let me run the full test suite to confirm everything still passes:
Assistant
All green. Let me amend the commit with the cleanup:
Assistant
Let me restore the nolints again — they got lost somehow:
Assistant
Good. Now amend without running fmt this time (which strips them):
Assistant
Clean — committed.go no longer in the diff (matching main), and the nolints are restored. Final verification:
Assistant
Lint clean, tests pass. Final commit c497be5b7.
Summary of cleanup
Fixed (6 of the 14 findings):
Extracted newSkippedResult helper — DRYs the skip-result construction. Used at both the pre-redaction skip site and inside skipIfPostRedactionEmpty.
Dropped hasShadowBranch parameter from skipIfPostRedactionEmpty — was only used for one nice-to-have log field, didn't gate the skip decision. Signature now 5 params instead of 6.
Trimmed multi-paragraph helper comments — redactOrDrop and skipIfPostRedactionEmpty now have single-sentence WHY comments instead of multi-paragraph rationale.
Removed redundant inline comment in filterFilesTouched — the function-level comment already explains the gate.
Replaced "line 165" references in test comments — they would rot. Now describe the gate structurally ("the pre-redaction skip gate").
Generalized filterFilesTouched rationale — kept Codex as a concrete historical example but framed the comment around what kind of session it catches, not as Codex-specific.
Skipped (8 findings):
Test mocking helper for redactSessionJSONLBytes swap — single use, abstracting would be over-engineering
Inlining sessionHasEvidenceOfWork — the named function IS the documentation of WHY
Reuse findings for redaction-failure handling and evidence-of-work predicates — different contexts, no real duplication
Test helper for git commits — current verbosity reads cleanly
All efficiency findings — costs are negligible
Net result: -27 lines (-25 produced + the cleanup removed more than it added). Branch soph/prevent-empty-sessions at c497be5b7, lint clean, all strategy tests passing.
User
ok, then now look at the codex specific things (b+c)
Assistant
Let me create tasks and start on the Codex-specific PR.
Assistant
Let me set up a fresh branch off main for PR (b+c):
Assistant
Good — fresh branch off main. Now let me look at the exact code to modify:
Assistant
Now I'll make the change. I'll add an early return right after sessionID validation, before any state-creating operations:
Assistant
Now I need a test. Let me see how existing tests for this file are structured:
Assistant
Let me check the session state file naming:
Assistant
Now I'll add the test:
Assistant
The existing test TestHandleLifecycleTurnStart_WritesPromptContent didn't set SessionRef so it now triggers the new ephemeral-skip. That test needs updating — real non-ephemeral sessions always have a SessionRef. Let me check CapturePrePromptState to understand what SessionRef it needs:
Assistant
The existing test used empty SessionRef, which doesn't reflect any real-world agent. Let me update it to pass a valid SessionRef so it still exercises the prompt-write path:
Assistant
All pass. Let me run the full cli package tests to make sure nothing else broke:
Assistant
Now full check:
Assistant
Clean now — only my intended changes. Let me run the full check:
Assistant
I'll update the bare SimulateUserPromptSubmit to pass a synthetic transcript path (all 132 callers effectively needed one):
Assistant
Let me check if filepath is already imported:
Assistant
Good — SimulateUserPromptSubmitWithTranscriptPath takes the path explicitly, so I can pass "" for ephemeral testing. Now let me update the two failing regression tests to use explicit empty SessionRef and assert the new "no session state" contract:
Assistant
Still used. Good. Now let me look at the third failure — TestSubdirectory_EntireDirCreatedAtRepoRoot:
Assistant
Now run integration tests again:
Assistant
Let me try a simpler fix — the test might have had an implicit assumption about empty-path flow. Let me check what env.GetRewindPoints() needs:
Assistant
The test has unrealistic ordering — it writes the transcript BEFORE UserPromptSubmit. In real life, UserPromptSubmit fires first (transcript empty), then agent works and appends to transcript, then Stop. With my change, the hook captures position from the pre-written transcript, leaving nothing "new" for SaveStep. Let me reorder the test:
Assistant
Now the remaining TestEmptySession_NoTranscriptPath_NotCondensed:
Assistant
Good, session package still used. Let me run the full integration suite:
Assistant
All integration tests pass. Now the full check:
Assistant
Found it — golangci-lint run --fix strips the nolints. Let me check the entire script:
Assistant
Now lint without --fix:
Assistant
With --new-from-rev=origin/main, 0 issues (which is what CI does). The 3 issues are all pre-existing from main and not introduced by my PR. Good.
Assistant
Clean diff — only my intended changes. Now let me run the full test suite once more (not mise run check since that applies --fix):
Assistant
All green. Now commit:
Assistant
Done. Branch soph/skip-ephemeral-codex-session has commit 00170d287 off origin/main.
Summary
What changed in lifecycle.go:
Added early return in handleLifecycleTurnStart when event.SessionRef == "". Skips CapturePrePromptState, prompt.txt write, and InitializeSession — no session state registered for ephemeral sessions. Logs Info that the session was skipped.
What changed in test infrastructure:
Added a defaultTranscriptPath helper on HookRunner that returns a synthetic path from ClaudeProjectDir + sessionID + ".jsonl"
Updated SimulateUserPromptSubmit, SimulateUserPromptSubmitWithPrompt, SimulateUserPromptSubmitWithResponse, SimulateUserPromptSubmitWithOutput to use this default instead of passing "". The "" default was an artifact — all 132 callers effectively needed a non-empty path to match real agent behavior.
What changed in existing tests:
TestEmptySession_NoTranscriptPath_NotCondensed and TestEmptySession_ActiveDuringCommit_NotCondensed: use SimulateUserPromptSubmitWithTranscriptPath(id, "") explicitly for the Codex companion scenario and assert that no session state is registered (new contract)
TestSubdirectory_SaveStepFromSubdir: reordered session.CreateTranscript to run AFTER UserPromptSubmit (matches the real lifecycle; previously the transcript was pre-written, which now confused the pre-prompt position capture)
TestSubdirectory_EntireDirCreatedAtRepoRoot and its TestHandleLifecycleTurnStart_WritesPromptContent sibling: updated to pass a synthetic transcript path
New test:
TestHandleLifecycleTurnStart_EphemeralSessionSkipped in lifecycle_test.go — direct unit test that verifies no state file and no prompt.txt are created when SessionRef is empty
Verified:golangci-lint run --new-from-rev=origin/main ./... → 0 issues. Full go test -tags=integration -race ./... passes.
(Side note on lint: mise run lint runs golangci-lint with --fix which strips some pre-existing-but-stale nolint directives, triggering a chicken-and-egg with ireturn. Those nolints exist on main; they'll only show up to lint as "unused" when my diff pulls their packages into analysis. CI uses --new-from-rev so it's clean. Not introduced by my PR.)
Two PRs ready for review:
soph/prevent-empty-sessions — Q1 guards (2 defensive gates in CondenseSession)
soph/skip-ephemeral-codex-session — the Codex ephemeral fix
Make the filterFilesTouched fallback conditional on state.StepCount > 0. The fallback comment (line 377-381) says it's for mid-turn commits "before SaveStep records FilesTouched". But for a session that never ran SaveStep, we're essentially making it steal attribution for another session's files. If StepCount == 0, don't apply the fallback — leave FilesTouched empty so the upstream skip gate catches it on the next condense.
Either alone would have prevented this specific stub. I'd do both — they're cheap and close real holes.
Q2: Why Codex subagent hooks don't fire
The report's hypothesis matches Codex's documented behavior in cmd/entire/cli/agent/codex/AGENT.md:200:
No subagent hooks: No PreTask/PostTask equivalent for subagent spawning.
/codex:adversarial-review likely spawns Codex via codex exec from within a Claude Code turn. codex exec is one-shot — it fires SessionStart and UserPromptSubmit at startup, but whether Stop fires reliably when the exec subprocess exits is a Codex upstream question. The session stays ACTIVE because nothing flipped it to IDLE.
Two debugging angles worth pursuing (don't have to be simultaneous):
Instrument at the call site: add a log at each of the three Codex hooks (session-start/user-prompt-submit/stop) that prints to a known file with session_id + pid. Run /codex:adversarial-review and check whether Stop lands at all. If Stop does fire but the stdin payload has a different session_id (e.g., exec uses a fresh session id per invocation), that's your bug.
Fallback path: since we already know how to read the rollout from disk (extractSessionData does it), we could add a "sweep stale ACTIVE Codex sessions with rollouts" step — if a Codex session's rollout has a completed turn but we never got Stop, finalize it during entire doctor or at the next PostCommit. This doesn't fix the missing hook, but it prevents the session from lingering.
Want me to implement the Q1 guards as a focused PR (two small changes + a test), and file an investigation task for Q2?
turn_complete
task_complete
LastInteractionTime
Instrument on our side, not Codex's. Add a line-append to .entire/logs/codex-lifecycle.log from each of the three hook commands (session-start / user-prompt-submit / stop) with session_id, pid, ts. That's the debugging harness you want the first time someone says "it happened again" — we'll instantly see whether Stop fired or not.
Don't wait on upstream for SessionEnd. The AGENT.md note ("No SessionEnd hook") is a known gap — the error-path skip makes it worse. A entire doctor --reconcile pass that reads ACTIVE Codex sessions' rollouts and finalizes them would be a good fallback, but #1 handles the common case without user action.
The Q1 guards I proposed earlier still stand — they fix the symptom (stub checkpoints), and #1 above fixes the cause (missing SaveStep) so those guards would only catch truly empty sessions, not legitimate Codex work we lost.
Want me to draft the Q1 guards (2 small changes) and a minimal version of #1 (read rollout at condense time for ACTIVE external agents) as a single PR? Or split them?
Accept ephemeral and capture what we can. Change lifecycle.go:322 to not-bail on empty SessionRef; instead run a degraded SaveStep that records the prompt + last_assistant_message (we have both from hook payloads) and skips transcript copying. Stub-free, but partial data.
I'd do #1 first as the fast fix and consider #2 separately — the juice from partial capture may not be worth the complexity given how the rest of the pipeline assumes a readable transcript.
The real lead is still finding what's actually invoking Codex this way. The reporter mentions codex-companion.mjs — a companion script that might be passing --ephemeral (or setting CODEX_HOME to something we can't see, same effect). Worth tracing that before committing to a fix.
Short version: yes, timeout is a better story than the error-path theory was, and probably better than pure ephemeral. Reading codex-companion.mjs would disambiguate definitively — want me to look for it in the usual places?
⎿ (timeout 10m)
⎿ 1 PostToolUse hook ran
This is strange, so it shows a timeout but also that codex finished... I feel there should have been a hook fired
stop_hook_active=true
interrupted
For us, though, it doesn't actually help — the process is getting SIGKILLed, not SIGTERMed. SIGKILL can't be handled. So even a perfect Codex upstream fix doesn't save us from this case. The /codex:adversarial-review command would need to raise its timeout (palliative, not a fix) or run Codex outside the Bash tool's kill scope.
For the fix on our side — rollout reconciliation at condense time becomes even more clearly the right move. Irrespective of whether Stop fires, crashes, or gets SIGKILLed, the rollout file at TranscriptPath (when it's non-null — which it should be when not in ephemeral mode) is the source of truth. At condense time, if we see an ACTIVE session with a readable rollout and a Turn completed-equivalent marker in the JSONL, finalize it ourselves and transition to ENDED. Zero dependence on Codex or on the invoking harness.
Quick verification you could do right now: read one of those three stuck session state files and check the transcript_path field. If it's a real path, case closed (timeout-kill theory); if empty, ephemeral mode was in play too. Either way, the condense-time-reconciliation fix covers both.
Revised Q2 fix: the rollout-reconciliation idea I pitched earlier is useless here — there's no rollout to reconcile. Two real options:
Accept ephemeral sessions as first-class. Change the turn-start/turn-end handlers so null transcript_path is valid. Capture what the hook payloads give us directly: prompt from UserPromptSubmit, last_assistant_message from Stop, turn IDs from both. No transcript file means no full transcript capture, but we'd at least produce a proper checkpoint with prompt + summary, transition phase cleanly, and avoid the stuck-ACTIVE + stub-metadata outcome.
Refuse ephemeral sessions at SessionStart. Log a warning ("Entire doesn't support ephemeral Codex sessions; this turn will not be captured") and don't register the session at all. Clean, but the user loses any record of their adversarial-review runs.
I'd lean #1 because adversarial-review is a legitimate workflow that users will want captured — even partial capture (prompt + final message + files_touched) beats nothing. And it's not that hard: we already have the structured data from hook payloads; we just currently ignore everything after the SessionRef check fails.
Q1 guards still stand and become more important under #1 — if we're accepting ephemeral sessions, the "don't write stub metadata.json when there's no transcript AND StepCount==0" guard is what keeps us from producing empty checkpoints when things still go sideways.
Want me to scope this as a single PR: (a) Q1 guards, (b) accept ephemeral turn-end with partial-capture path, (c) instrumentation log so we catch any remaining edge cases? That's three independent changes but they all aim at the same class of bug.
now
EventTurnStart
LastInteractionTime
handleLifecycleTurnEnd (lifecycle.go:322-324) — bails immediately on empty SessionRef.
So the correct causal chain for the stuck sessions is:
Plugin calls thread/start + review/start over app-server
Codex fires SessionStart → we don't create state, just drop a model hint
Codex fires UserPromptSubmit → we create state here (initializeSession + TurnStart transition → the 1ms fingerprint)
Codex runs turn, fires Stop with null transcript_path → we bail, no state mutation
Session stays ACTIVE forever
Implication for the fix
The guard I suggested ("refuse ephemeral at SessionStart") won't work — we don't do anything in SessionStart that we could refuse. The actual decision point is in handleLifecycleTurnStart where InitializeSession is called. If we want to refuse ephemeral sessions, we'd check event.SessionRef == "" there and skip state creation entirely. That's probably the cleanest fix, and it's a single branch.
The "accept ephemeral and capture partial" option (my #1 earlier) is still viable but requires more surgery — you have to teach turn-end, condensation, and the skip-gate to handle sessions with no transcript file. More payoff, more work.
I'd still lean toward the minimal refuse-at-turn-start fix unless you actually want the adversarial-review output captured.
codex --ephemeral
--ephemeral
The Q1 guards (skip metadata.json when StepCount==0 and no transcript; conditional filterFilesTouched fallback) still want to land regardless — they're independent backstops.
Want me to scope the PR as: (a) Q1 two guards, (b) skip-InitializeSession-when-SessionRef-empty + warning log, (c) a test that simulates the ephemeral Codex flow end-to-end?