Skip to content

app-server: claim thread teardown groups atomically#31400

Closed
winston-openai wants to merge 2 commits into
dev/winston/app-server-exact-teardown-admissionfrom
dev/winston/app-server-atomic-tree-teardown
Closed

app-server: claim thread teardown groups atomically#31400
winston-openai wants to merge 2 commits into
dev/winston/app-server-exact-teardown-admissionfrom
dev/winston/app-server-atomic-tree-teardown

Conversation

@winston-openai

@winston-openai winston-openai commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Generalize the tracked teardown coordinator from one ThreadId to an exact operation-owned group. Initial claims deduplicate and preflight the complete ID set under one registry lock, while group extensions immediately own free IDs and register an exact weak successor for every contested ID.

A coordinator-wide affine freeze guard serializes tree-discovery and extension phases even when callers must drop the app-server thread-list permit to await an older teardown. When that predecessor releases, the registry transfers each contested ThreadId directly to the live successor before signaling completion. This removes both cross-extension deadlocks and the scheduler-sized admission gap where a descendant could otherwise be resumed or attached.

Operation identity, exact Arc release checks, and cancellation-aware weak handoffs keep stale owners from removing or resurrecting successor claims. Existing single-ID idle unload and cleanup continue through compatibility wrappers backed by the same coordinator.

Stacked on #31399. The next layer uses this primitive for complete-tree teardown and retains the same claim through archive/delete mutation or same-ThreadId successor publication.

Validation

  • Coordinator tests cover provisional cancellation, singleflight lifetime, multi-owner conflict deduplication, free-sibling ownership during waits, gapless handoff, freeze serialization, stale successor cancellation, and drain behavior.
  • Existing lifecycle reservation and unsubscribe suites pass through the single-ID adapters.
  • just fix -p codex-app-server
  • just fmt

@winston-openai

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 1f6c042c0f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@winston-openai

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: b2c07ba8d8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

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