Skip to content

[app-server] let idle auto-attached threads unload - #30985

Closed
chess-oai wants to merge 1 commit into
mainfrom
chess/idle-auto-attached-threads
Closed

chess-oai wants to merge 1 commit into
mainfrom
chess/idle-auto-attached-threads

Conversation

@chess-oai

Copy link
Copy Markdown
Contributor

summary

  • distinguish implicit observer attachments from explicit retaining subscriptions while preserving event and server-request delivery
  • allow idle core-created threads with no explicit subscribers to reach the existing 30-minute unload lifecycle
  • use retaining-subscriber semantics for running resume overrides and preserve the full idle grace period across coalesced watcher edges

why

app-server auto-attaches every initialized connection to internally created threads so clients can observe events and answer requests. those delivery-only attachments currently share subscription bookkeeping with explicit thread/start, thread/resume, and thread/fork requests, so the idle-unload watcher never sees zero subscribers. this leaves otherwise idle threads and their session resources loaded indefinitely

testing

  • just test -p codex-app-server --test-threads=2 (936 passed, 1 skipped)
  • focused implicit/explicit, mixed-state, reactivation, coalesced-edge, and running-resume regressions
  • just fix -p codex-app-server
  • just fmt

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@zierocode

Copy link
Copy Markdown

I refreshed this fix onto current main (6c00dc087e) and resolved the two app-server conflicts without changing the protocol or isolation boundaries.

Refreshed commit: zierocode@fb3ab90
Branch: https://github.com/zierocode/codex/tree/codex/idle-auto-attached-threads

Verification on the refreshed tree:

  • just test -p codex-app-server: 981 passed, 1 skipped
  • just fix -p codex-app-server and just fmt: clean
  • focused coverage includes implicit delivery without retention, implicit-to-explicit upgrade, connection removal, and last-explicit-subscriber behavior
  • exact installed-tag RED/GREEN validation plus a 30-minute runtime soak confirmed MCP child processes and RSS return to baseline after idle unload

The repository currently limits new pull requests to collaborators, so I cannot open a replacement PR from the fork. A maintainer can cherry-pick fb3ab904c27fcdef6f035dcd7dc59229212476e2 or update this PR head with the refreshed tree. I am not signing or accepting the CLA on behalf of the original author.

Copy link
Copy Markdown

I independently reproduced the lifecycle issue from #11324 and prepared a current-main fork patch that overlaps this draft while adding coverage for two ownership paths and the unload race:

During review, I found that normal turn/start and inline review/start could still submit work from an Auto-attached connection without upgrading it to retaining ownership. Near the unload deadline, those paths could also race the closing commit. The fork patch adds a serialized admission helper under the pending-unload lock and calls it immediately before normal turn and inline-review submission. The request either wins with Auto→Explicit ownership established or fails after closing is committed.

Additional regression coverage includes:

  • real automatic event delivery through an internally spawned child
  • direct turn/start ownership upgrade without resume
  • committed-closing rejection without mutating the Auto attachment
  • exact 30-minute deadline and resubscription reset
  • last-owner unsubscribe/disconnect grace
  • transcript-preserving cold resume
  • inline-review submission

Focused tests pass, along with just fix -p codex-app-server, just fmt, and git diff --check. The upstream repository currently rejects PR creation from this account, so a maintainer would need to compare/cherry-pick the fork commit or incorporate the additional admission/test changes into this draft.

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.

3 participants