feat: finalize Codex threads 30 minutes after they go quiet - #86
Merged
Conversation
Codex threads now get the full pipeline — embeddings, episodes, project inference — on their own, once the rollout has been untouched for DEFAULT_FINALIZE_AFTER_SECONDS (1800). It is the Codex twin of Claude Code's SessionEnd hook: Codex sends no session-end signal, so quiet stands in. Before this, an active thread indexed with `--semantic` regressed to exact-record-only the moment it grew (the poller re-captured it as `archived`) and nothing ever indexed it again. - `scan_codex_sessions(min_idle_seconds=…)` adds a `settling` bucket for rollouts written more recently than the bound; `sync_codex` passes it through and reports it. - `finalize_codex()` scans for quiet, un-analyzed rollouts and only then builds the LonghandStore, so the every-minute poller never loads the embedding model unless a thread is waiting; one thread per run. - `codex-sync` runs it after the exact-record pass (`--finalize-after`, `--no-finalize`); `--semantic` is unchanged. The installed LaunchAgent needs no change. - `reconcile --fix` clears the whole quiet backlog under its own lock; the report gains codex_unfinalized / codex_settling / codex_finalized. - doctor: "Codex sessions archived" becomes "Codex finalizer" — green while archived threads are still being written, yellow only when one has been quiet past the bound and nothing finalized it. Tests: 8 new (scan bucket, finalizer wait/run/resume, reconciler, CLI model-load guard, CLI finalize + opt-out, doctor row, reconcile output); 588 passing, ruff/format/mypy clean. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPdAP75f7yqXQwmFUtjuVM
Merged
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.
What
Codex threads now get the full pipeline — embeddings, episodes, project inference — on their own, once the rollout has been untouched for 30 minutes (
DEFAULT_FINALIZE_AFTER_SECONDS = 1800). It is the Codex twin of Claude Code's SessionEnd hook: Codex sends no session-end signal, so quiet stands in for it.Why
Seen live on 2026-09-07:
codex-sync --semanticembedded 5 threads; within a minute the active thread grew, the 60-second poller re-captured it exact-record-only, and its stage regressed toarchived. Nothing ever indexed it again. Live capture already mirrored Claude's Stop hook; the SessionEnd half was missing.How
scan_codex_sessions(min_idle_seconds=…)adds asettlingbucket for rollouts written more recently than the bound;sync_codexpasses it through and reports it.Nonekeeps live capture unchanged.finalize_codex(sqlite, codex_home, build_store)scans for quiet, un-analyzed rollouts (stat calls only) and callsbuild_storeonly when one exists — so the every-minute poller never loads the embedding model unless a thread is waiting. One thread per run.codex-syncruns it after the exact-record pass by default (--finalize-after SECONDS,--no-finalize);--semanticunchanged. The shipped LaunchAgent template needs no change.reconcile --fixclears the whole quiet backlog under its own lock (it already holds the model); the report and MCP tool gaincodex_unfinalized/codex_settling/codex_finalized.doctor: "Codex sessions archived" becomes "Codex finalizer" — green while archived threads are still being written, yellow only when one has been quiet past the bound and nothing finalized it.Tests
8 new in
tests/test_codex.py(scan bucket; finalizer waits, runs, and recovers after a resume; reconciler with a real store; CLI never loads the model while threads settle; CLI finalizes +--no-finalize; doctor row; reconcile output). 588 passing; ruff, format, mypy clean. README test badge 580 → 588 (enforced bytest_surface_consistency).Docs:
docs/codex.md, README "Works with Codex", CLAUDE.md Codex note, CHANGELOG[Unreleased].🤖 Generated with Claude Code
https://claude.ai/code/session_01PPdAP75f7yqXQwmFUtjuVM