Skip to content

feat: add thread lifecycle contributor hooks#22476

Merged
jif-oai merged 3 commits into
mainfrom
jif/thread-life-cycle
May 13, 2026
Merged

feat: add thread lifecycle contributor hooks#22476
jif-oai merged 3 commits into
mainfrom
jif/thread-life-cycle

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai commented May 13, 2026

Why

Extensions that need thread-scoped state currently only get a start-time callback. That is enough for seeding stores, but it leaves the host without a shared extension seam for later thread rehydrate and flush work as thread ownership evolves. This PR turns that start-only seam into a host-owned thread lifecycle contributor contract so extension-private state can stay behind the extension API instead of leaking extra orchestration through core.

What changed

  • Replaced ThreadStartContributor with ThreadLifecycleContributor and added typed lifecycle inputs for thread start, resume, and stop. The contract lives in contributors/thread_lifecycle.rs.
  • Kept the existing start-time behavior intact by routing session construction through on_thread_start.
  • Invoked on_thread_stop during session shutdown before thread-scoped extension state is dropped, while isolating contributor failures behind warning logs.
  • Migrated git-attribution and guardian onto the lifecycle registration path.
  • Renamed the extension registry plumbing from start-specific contributors to lifecycle-specific contributors.

Notes

on_thread_resume is introduced at the API boundary here so extensions can target the final lifecycle shape; host resume dispatch can be wired where that runtime path is finalized.

@jif-oai jif-oai requested a review from a team as a code owner May 13, 2026 10:49
@jif-oai jif-oai changed the title feat: thread life cycle contributor feat: add thread lifecycle contributor hooks May 13, 2026
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 13, 2026

@codex review

Copy link
Copy Markdown
Contributor

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

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: f89ea3757b

ℹ️ 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/core/src/session/session.rs
Comment thread codex-rs/ext/extension-api/src/registry.rs
@jif-oai jif-oai merged commit 5ab7e6b into main May 13, 2026
27 checks passed
@jif-oai jif-oai deleted the jif/thread-life-cycle branch May 13, 2026 11:11
@github-actions github-actions Bot locked and limited conversation to collaborators May 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants