Skip to content

fix(codex): preserve supervision across checkpoints - #1158

Draft
dilipgv wants to merge 1 commit into
kunchenguid:mainfrom
dilipgv:dv/codex-supervision-reliable
Draft

fix(codex): preserve supervision across checkpoints#1158
dilipgv wants to merge 1 commit into
kunchenguid:mainfrom
dilipgv:dv/codex-supervision-reliable

Conversation

@dilipgv

@dilipgv dilipgv commented Jul 28, 2026

Copy link
Copy Markdown

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

  • Track bounded-checkpoint versus durable watcher ownership separately, and block the first Codex Stop when only the bounded checkpoint owner is live so checkpoint expiry falls back to a model continuation that drains the wake queue and starts the next checkpoint instead of silently ending supervision.
  • Extend fm-turnend-guard.sh, fm-wake-lib.sh, fm-watch.sh, and fm-watch-checkpoint.sh with the ownership-recording and stop-blocking logic, while preserving stop_hook_active loop safety, durable watcher acceptance, lock exclusivity, and exact-once actionable wakes.
  • Add regression coverage for the stop-while-checkpoint-live case and for two consecutive quiet checkpoint cycles, and update the Codex supervision, architecture, and verification docs to describe the new ownership contract.

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 new test_stop_guard_rejects_live_bounded_checkpoint (the stop-while-checkpoint-live regression) and test_two_quiet_checkpoints_reacquire_and_release_cleanly/test_registered_check_fires_after_two_quiet_boundaries
  • bash 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 change
  • git diff b29621b..c616fc8 review 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.

@dilipgv
dilipgv marked this pull request as draft July 28, 2026 02:14
@dilipgv
dilipgv force-pushed the dv/codex-supervision-reliable branch from c616fc8 to bf002bc Compare July 28, 2026 17:44
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