fix(codex): preserve supervision across checkpoints - #1158
Draft
dilipgv wants to merge 1 commit into
Draft
Conversation
dilipgv
marked this pull request as draft
July 28, 2026 02:14
dilipgv
force-pushed
the
dv/codex-supervision-reliable
branch
from
July 28, 2026 17:44
c616fc8 to
bf002bc
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.
Intent
Fix Firstmate Codex supervision so a bounded foreground checkpoint cannot be mistaken for durable turn-end supervision. Record bounded-checkpoint versus durable watcher ownership; block the first Codex Stop when only the bounded owner is live so checkpoint expiry returns to a model continuation that drains the durable wake queue, handles user steering, and immediately starts the next checkpoint. Preserve stop_hook_active loop safety, durable watcher acceptance, lock exclusivity, read-only lock refusal, other harness protocols, and exact-once actionable wakes. Do not add a daemon, shell-background supervision, broad pkill, a Trello special case, or a longer timeout. Add regressions for the exact stop-while-checkpoint-live incident and at least two quiet checkpoint cycles, update the Codex supervision and verification docs, push dv/codex-supervision-reliable to the configured fork, and open a draft PR to kunchenguid/firstmate without reviewers, readying, merging, or committing generated artifacts.
What Changed
fm-turnend-guard.sh,fm-wake-lib.sh,fm-watch.sh, andfm-watch-checkpoint.shwith the ownership-recording and stop-blocking logic, while preservingstop_hook_activeloop safety, durable watcher acceptance, lock exclusivity, and exact-once actionable wakes.Risk Assessment
✅ Low: The change is small, self-contained to the Codex checkpoint/turnend-guard path, defaults safely to "durable" for pre-existing locks (backward compatible), writes the new supervision-owner marker before the identity file so no unsafe race window exists, cleans up the marker on lock release, and is covered by new regression tests for the exact incident (stop-while-checkpoint-live) plus repeated quiet-cycle and durable-watcher-acceptance cases; docs were updated consistently with the code.
Testing
Ran the full checkpoint test suite (all pass, including the two new regressions that directly reproduce the stop-while-checkpoint-live incident and quiet-cycle safety) and the turnend-guard suite (35/36 pass, with the single failure confirmed pre-existing on the base commit and unrelated to this change); the working tree was left clean with no stray artifacts.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-watch-checkpoint.test.sh— all 7 tests pass, including newtest_stop_guard_rejects_live_bounded_checkpoint(the stop-while-checkpoint-live regression) andtest_two_quiet_checkpoints_reacquire_and_release_cleanly/test_registered_check_fires_after_two_quiet_boundariesbash tests/fm-turnend-guard.test.sh— 35/36 pass; verified the one failing case ('OpenCode plugin must run the guard from worktree even when directory is elsewhere') fails identically on base commit b29621b, confirming it's pre-existing and unrelated to this changegit diff b29621b..c616fc8review of bin/fm-turnend-guard.sh, bin/fm-wake-lib.sh, bin/fm-watch.sh, bin/fm-watch-checkpoint.sh to confirm the supervision-owner file mechanism and block logic match the described behavior✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.