Skip to content

fix(cli): stop a second Codex restore after graceful shutdown (rebase of #3164) - #3187

Merged
lidge-jun merged 1 commit into
devfrom
codex/3164-restore-warning
Sep 1, 2026
Merged

fix(cli): stop a second Codex restore after graceful shutdown (rebase of #3164)#3187
lidge-jun merged 1 commit into
devfrom
codex/3164-restore-warning

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

Summary

Maintainer rebase of #3164 by @x3M3x onto current dev — cherry-picked with author credit preserved, no conflicts.

A graceful proxy shutdown already performs the shared Codex/Grok teardown, but ocx stop, ocx update, and related lifecycle commands attempted a second Codex resume-history restore afterwards, so the user saw the restore warning twice. The proxy now records that it did the teardown itself, and the caller skips its own restore in that case. Caller-side restoration is preserved for deferred receipts and the hard-kill fallback, which are the paths where the proxy did not get to do it.

Verification

Exact head 605f0acb7:

  • bun test ./tests/grok-lifecycle.test.ts ./tests/process-control-graceful.test.ts ./tests/update-stop-first.test.ts54 pass, 0 fail, 347 expect() calls.

Full-suite and typecheck coverage is left to CI on this exact head. The original PR reported unrelated Windows timing/ACL and spill-publication failures in responses-state and neighbours; those are the known environment-dependent set, not this diff.

Checklist

  • Targets dev
  • Author credit preserved
  • No unresolved review threads on the original
  • The fallback paths that still need caller-side restore are preserved rather than blanket-disabled
  • No credential, auth, workflow, or release-automation surface touched

@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 1, 2026 17:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T17:31:04.253155Z 605f0ac PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lidge-jun
lidge-jun merged commit d335570 into dev Sep 1, 2026
12 checks passed
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@lidge-jun
lidge-jun deleted the codex/3164-restore-warning branch September 1, 2026 17:28
@github-actions github-actions Bot added the bug Something isn't working label Sep 1, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 605f0acb78

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/index.ts
// receipt could not be written, the proxy restores it itself and the caller must not
// attempt a second restore after a graceful stop. A hard-kill always leaves restore
// to this process.
return graceful && !teardownNonce;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve graceful teardown failures before skipping restore

When the receipt cannot be written and the daemon's own teardown fails, /api/stop still returns HTTP 200 with { success: false } and then exits with status 1, but stopProxyGracefully checks only res.ok and process disappearance. Consequently this expression marks the teardown as handled, blocks the caller-side retry, leaves stopFailed false, and lets ocx stop or an update report success while native Codex or Grok remains pointed at the dead proxy. Parse and propagate the teardown result (or otherwise distinguish an unsuccessful graceful exit), and skip the caller restore only after confirmed teardown success; add a focused behavioral test for the failure response rather than only source-string assertions.

AGENTS.md reference: src/AGENTS.md:L24-L25

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants