Repository navigation
Promote fallback-latest to live inside the matching orchestrator - #9
Merged
Merged
Conversation
Claude Code never exports CLAUDE_SESSION_ID to subshells, so the env-var path in resolve_transcript_target is unreachable on the native shell and every brain build was downgraded to fallback-latest. Codex exposes CODEX_THREAD_ID so its live detection works, but the asymmetry made munin brain look broken to Claude Code users. When CLAUDECODE=1 (or CODEX_HOME/CODEX_THREAD_ID for Codex) is set AND the latest matching transcript was modified within the last 120s, treat it as live. Older idle transcripts stay fallback-latest; >24h still goes stale. Decision logic extracted into a pure function (decide_source_status) so the behaviour is unit-testable without env mocking. Four regression tests cover the matrix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
inchwormz
force-pushed
the
fix/claude-live-session-detection
branch
from
April 20, 2026 20:47
4afaa01 to
2ba69a1
Compare
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.
Summary
CLAUDE_SESSION_IDto subshells, soresolve_transcript_target's env-var path was unreachable on the native shell — everymunin brainbuild was downgraded tofallback-latestand the brain skill correctly refused to trust the result.CODEX_THREAD_IDso its live detection works; the asymmetry mademunin brainlook broken on Claude Code.CLAUDECODE=1(orCODEX_HOME/CODEX_THREAD_IDfor Codex) is set AND the chosen transcript was modified within 120s, treat it aslive. Older idle transcripts stayfallback-latest; >24h still goesstale.decide_source_status()so behaviour is unit-testable without env mocking. Four regression tests cover the matrix.Verification
cargo test --lib: 317 passed (4 new regression tests fordecide_source_status).munin brain --format promptfrom the project root now reportssource_status="live"with the correct active session id.Test plan
cargo test --lib session_brain::messages::tests— 11 passedcargo test --libfull suite — 317 passedfallback-latest→live🤖 Generated with Claude Code