Skip to content

code-mode: extend test coverage to lock in cell lifecycle#28468

Merged
cconger merged 1 commit into
mainfrom
cconger/code-mode-runtime-compact-01-contract
Jun 16, 2026
Merged

code-mode: extend test coverage to lock in cell lifecycle#28468
cconger merged 1 commit into
mainfrom
cconger/code-mode-runtime-compact-01-contract

Conversation

@cconger

@cconger cconger commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

This PR establishes the intended behavior as an executable contract before a refactor of the cell runtime begins. It also fixes cases where a second observer or termination request could replace an existing response channel and leave the original caller unresolved.

Behavior codified

  • A cell can yield output and subsequently resume to completion.
  • A caller can run a cell until it has no immediately runnable work, receive its accumulated output and outstanding tool-call IDs, and then resume the same cell when the awaited work is available.
  • Each cell admits one active observer:
    • a second observer receives an explicit busy error
    • the existing observer remains registered and is not displaced
  • A natural result (conclusion of the js module) that has already reached the cell controller wins over a later termination request.
  • Otherwise, termination preempts execution and resolves both:
    • the active observer, if present
    • the caller requesting termination
  • Repeated termination requests are rejected while termination is already in progress.
  • Terminal responses are sent only after outstanding callback work has been handled:
    • natural completion drains notifications and cancels outstanding tool calls
    • termination cancels and drains both notification and tool callbacks.
  • Cell removal and cell_closed notification happen after callback cleanup

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

Copy link
Copy Markdown
Contributor

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: 03eec933ea

ℹ️ 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 codex-rs/code-mode/src/service.rs
Comment thread codex-rs/code-mode/src/service_contract_tests.rs
@cconger
cconger force-pushed the cconger/code-mode-runtime-compact-01-contract branch 2 times, most recently from bc4a140 to 80f8653 Compare June 16, 2026 07:26
@cconger
cconger requested a review from a team as a code owner June 16, 2026 07:26
@cconger
cconger force-pushed the cconger/code-mode-runtime-compact-01-contract branch 2 times, most recently from 1a0b289 to 8df3577 Compare June 16, 2026 16:54
Comment thread codex-rs/code-mode/src/service.rs Outdated
};
if handle
.termination_requested
.compare_exchange(false, true, Ordering::AcqRel, Ordering::Acquire)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: if we're not actually protecting any data with synchronization points between these atomic ops, might as well use relaxed everywhere

Comment thread codex-rs/core/tests/suite/code_mode.rs Outdated
let code = r#"// @exec: {"yield_time_ms": 100}
text("phase 1");
let code = r#"// @exec: {"yield_time_ms": 0, "max_output_tokens": 16}
for (let index = 0; index < 512; index++) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: this seems like not many iterations, could this flake if timing gets weird in a cloud vm that's running tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Bumped this to a much larger cycle, proved failure without and readded, agree that this is kinda "magic", there is a deterministic test to verify the behavior in the code-mode tests, but this tries to capture it at the suite level too.

@cconger
cconger force-pushed the cconger/code-mode-runtime-compact-01-contract branch from 8df3577 to eac98a0 Compare June 16, 2026 19:13
@cconger
cconger merged commit e93516e into main Jun 16, 2026
31 checks passed
@cconger
cconger deleted the cconger/code-mode-runtime-compact-01-contract branch June 16, 2026 20:34
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants