Skip to content

fix(codex): keep lifecycle hooks cache-independent - #396

Merged
kengio merged 15 commits into
mainfrom
fix/codex-hook-runner
Aug 28, 2026
Merged

fix(codex): keep lifecycle hooks cache-independent#396
kengio merged 15 commits into
mainfrom
fix/codex-hook-runner

Conversation

@kengio

@kengio kengio commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a hidden Codex hook runner to the installed CLI so active tasks no longer depend on versioned plugin-cache files
  • keep hook execution fail-open with bounded child lifecycles, concurrent stdout draining, stable executable injection, and stale override validation
  • add streaming task list --limit selection with deterministic ordering and the full filtered total
  • add hidden checkpoint reset --session-token <TOKEN> so /wrapup resets the same cadence state the hook runner incremented, plus a hidden resolve-only session token verb for mid-session identity recovery that leaves that state untouched (review fixes), and cover the Stop hook's pending-embed dispatch with unit + integration tests

Verification

  • cargo test --workspace
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo build --workspace
  • python3 scripts/check-readme-version.py
  • real SessionStart cache-deletion smoke and task-list limit smoke
  • red-first + mutation checks: checkpoint reset --session-token errors on the pre-fix CLI; deleting the pending-embed spawn fails the new tests

Rollout

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.

kengio added 14 commits August 26, 2026 16:26
…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.
@kengio
kengio merged commit d862c05 into main Aug 28, 2026
22 checks passed
@kengio
kengio deleted the fix/codex-hook-runner branch August 28, 2026 03:00
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.

1 participant