Skip to content

fix(supervisor): serialize cancellation and terminal job state - #82

Merged
roodboi merged 3 commits into
mainfrom
codex/supervisor-cancellation
Sep 8, 2026
Merged

fix(supervisor): serialize cancellation and terminal job state#82
roodboi merged 3 commits into
mainfrom
codex/supervisor-cancellation

Conversation

@roodboi

@roodboi roodboi commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Problem and behavior

Cancelling a supervisor job could return cancelled while the run promise and persisted job ended as failed. The cancellation path killed the process before saving its state, allowing the exit path to race it with a second terminal write.

The runner now claims one terminal outcome synchronously and shares its persistence promise between cancellation and process exit. The service delegates cancellation to that owner. Accepted repeated requests reuse one outcome/event, and cancellation after completion has claimed its outcome returns not_running. A successful cancel response waits for metadata and the cancellation event, without waiting for process exit or output drain. Ordinary completion, nonzero failure, and API response shapes remain intact.

Persistence failures after a terminal claim now reject and are logged without allowing the service fallback to overwrite the claimed outcome. Partial metadata/event writes remain visible as errors; they are not reported as success or automatically retried.

Validation

  • Controlled storage barriers exercise process exit before the cancellation write and late cancellation during a completion write.
  • A real process that ignores SIGTERM verifies cancellation acknowledgement does not wait for process exit; the test explicitly terminates its child afterward.
  • Service coverage verifies persisted state, one cancellation event, no competing failure event, and cancellation after completion.
  • Disabling the shared terminal writer reproduces Expected: cancelled / Received: failed in the regression tests.
  • Bun 1.3.9: 908 tests passed, 5 skipped, 0 failed across 159 files. Uncached CLI/DB typecheck and lint, privacy checks, changed-file lint, and a fresh compiled build pass.
  • Four persistence fault cases cover failure before status save, before event append, after event append but before sequence update, and after completion persistence. Removing the claimed-outcome guard makes all four regressions fail.
  • All four final-head CI jobs passed (tests, secret scan, runtime images, Docker E2E): run 34188001911 at 73b1be7f16b5195bcd895bafb2675a5519ab5f7e.

Release

fix(supervisor) should produce a patch release. This repairs retained supervisor behavior and does not promote unsupported remote workflows into the default product. Follow-up source: project writeback WB-00004.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 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-08T04:50:12.854455Z 73b1be7 Manual request
🔒 Security Review Completed 2026-09-08T04:51:16.347464Z 73b1be7 Manual request
ℹ️ 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.

@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: 557290f9d9

ℹ️ 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/control-plane/extensions/supervisor/runner.ts
@roodboi

roodboi commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 73b1be7f16

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 73b1be7f16

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@roodboi
roodboi merged commit 450b64e into main Sep 8, 2026
5 checks passed
@roodboi
roodboi deleted the codex/supervisor-cancellation branch September 8, 2026 04:51
roodboi pushed a commit that referenced this pull request Sep 8, 2026
## [4.1.1](v4.1.0...v4.1.1) (2026-09-08)

### Bug Fixes

* **supervisor:** serialize cancellation and terminal job state ([#82](#82)) ([450b64e](450b64e))
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