fix(codex): keep lifecycle hooks cache-independent - #396
Merged
Conversation
…nding dispatch `onebrain hook` counts checkpoint cadence under the hash-16 token it derives from ONEBRAIN_HOOK_SESSION_ID, but /wrapup runs `checkpoint reset` from an agent shell that never sees that variable — so reset resolved a different token (CLAUDE_CODE_SESSION_ID truncated to 8 chars) and zeroed the wrong state file, leaving the cadence counter to survive every wrapup. `checkpoint reset --session-token <TOKEN>` (hidden, mirroring `session init --session-token`) now targets an already-resolved token verbatim — sanitized, never re-hashed — bypassing env resolution. Also covers the Stop hook's second child: deleting the `search reindex --pending-only` spawn used to pass the entire suite. A unit test asserts both invocations as an unordered set (the two children race on separate scoped threads) with their timeout and stdout-capture budgets, and the lifecycle integration test records the background child's argv through a FAKE_REINDEX_FILE marker.
…ty recovery session init always runs clean_stale_state_file, which deletes the Stop-hook cadence state file whenever its mtime predates process start -- always true mid-session -- silently wiping the checkpoint counter a mid-session token-recovery caller is trying to recover. `session token` (hidden) resolves the identical token through the identical resolve_session_token chain, with no vault resolution, no config load, no search probe, and no state-file cleanup -- so it is safe to call mid-session and works from any cwd.
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
checkpoint reset --session-token <TOKEN>so /wrapup resets the same cadence state the hook runner incremented, plus a hidden resolve-onlysession tokenverb for mid-session identity recovery that leaves that state untouched (review fixes), and cover the Stop hook's pending-embed dispatch with unit + integration testsVerification
checkpoint reset --session-tokenerrors on the pre-fix CLI; deleting the pending-embed spawn fails the new testsRollout
Companion plugin PR: onebrain-ai/onebrain#240.
Release CLI v3.4.25 before the companion OneBrain plugin v3.4.12 change. The plugin raises its CLI floor to 3.4.25.