Skip to content

app-server: run initialized rpcs with keyed serialization#17373

Merged
euroelessar merged 15 commits into
mainfrom
codex/concurrent-rpcs-stateful-serialization
Apr 28, 2026
Merged

app-server: run initialized rpcs with keyed serialization#17373
euroelessar merged 15 commits into
mainfrom
codex/concurrent-rpcs-stateful-serialization

Conversation

@euroelessar

@euroelessar euroelessar commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator

Why

Initialized app-server RPCs no longer need to bottleneck behind one request processor path. Running them concurrently improves responsiveness, but several request families still mutate shared state or depend on ordered side effects. Those stateful families need an auditable serialization contract so concurrency does not reorder thread, config, auth, command, watcher, MCP, or similar state transitions.

This PR keeps that boundary explicit: stateful work is serialized by the smallest useful key, while intentionally read-only or externally concurrent work remains unkeyed. In particular, thread/list and thread/turns/list explicitly have no serialization because they primarily read append-only rollout storage and should continue to be served concurrently.

What changed

  • Adds ClientRequest::serialization_scope() in app-server-protocol and requires every client request definition to declare its serialization behavior.
  • Introduces keyed request scopes for thread, thread path, command exec process, fuzzy search session, fs watch, MCP OAuth, and global state buckets such as config, account auth, memory, and device keys.
  • Routes initialized app-server RPCs through per-key FIFO serialization while allowing unkeyed initialized requests to run concurrently.
  • Cancels in-flight initialized RPC work when the connection disconnects or the app-server exits so spawned request tasks do not outlive their session.
  • Adds focused coverage for representative keyed and unkeyed serialization scopes, including explicitly concurrent thread/turns/list behavior.

Validation

  • Added protocol tests for representative keyed serialization scopes and intentionally unkeyed request families.
  • Added app-server request serialization tests covering per-key FIFO behavior, concurrent unkeyed execution, disconnect shutdown, and config read-after-write ordering.
  • Local focused protocol validation after the latest rebase is currently blocked by packageproxy failing to resolve locked rustls-webpki 0.103.13; CI is expected to provide the full validation signal.

@euroelessar euroelessar force-pushed the codex/concurrent-rpcs-stateful-serialization branch from 99c2450 to 3479ece Compare April 10, 2026 21:38
@euroelessar euroelessar force-pushed the codex/concurrent-rpcs-initialized-rpcs branch from 2435f00 to 8514a9b Compare April 10, 2026 21:55
@euroelessar euroelessar force-pushed the codex/concurrent-rpcs-stateful-serialization branch from 3479ece to c9bf9e4 Compare April 10, 2026 21:55
@euroelessar euroelessar changed the title app-server: serialize stateful rpcs by object key app-server: run initialized rpcs with keyed serialization Apr 10, 2026
@euroelessar euroelessar marked this pull request as ready for review April 10, 2026 22:38
@euroelessar euroelessar requested a review from owenlin0 April 10, 2026 22:38
@euroelessar euroelessar force-pushed the codex/concurrent-rpcs-initialized-rpcs branch from 8514a9b to 5c883c1 Compare April 10, 2026 23:49
@euroelessar euroelessar force-pushed the codex/concurrent-rpcs-stateful-serialization branch from c9bf9e4 to 7299bcc Compare April 10, 2026 23:49
Comment thread codex-rs/app-server/src/message_processor.rs
Comment thread codex-rs/app-server-protocol/src/protocol/common.rs Outdated
Comment thread codex-rs/app-server-protocol/src/protocol/common.rs Outdated
Comment thread codex-rs/app-server-protocol/src/protocol/common.rs Outdated
Comment thread codex-rs/app-server-protocol/src/protocol/common.rs
@euroelessar euroelessar force-pushed the codex/concurrent-rpcs-initialized-rpcs branch from 551d1b7 to 7e5a28b Compare April 13, 2026 18:26
@euroelessar euroelessar force-pushed the codex/concurrent-rpcs-stateful-serialization branch from 7299bcc to ef11e16 Compare April 13, 2026 18:53
@bolinfest bolinfest self-requested a review April 13, 2026 21:54
Base automatically changed from codex/concurrent-rpcs-initialized-rpcs to main April 14, 2026 18:24
@euroelessar euroelessar force-pushed the codex/concurrent-rpcs-stateful-serialization branch from 9ed94d1 to d62963b Compare April 27, 2026 23:41
euroelessar added a commit that referenced this pull request Apr 27, 2026
euroelessar added a commit that referenced this pull request Apr 27, 2026
@euroelessar euroelessar force-pushed the codex/concurrent-rpcs-stateful-serialization branch 2 times, most recently from d3d5a94 to 56486b1 Compare April 28, 2026 00:20
@euroelessar euroelessar force-pushed the codex/concurrent-rpcs-stateful-serialization branch from 56486b1 to 44d44fc Compare April 28, 2026 17:39

@owenlin0 owenlin0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks very reasonable to me! quite a nice declarative API too 👍

@euroelessar euroelessar merged commit 0700f97 into main Apr 28, 2026
25 checks passed
@euroelessar euroelessar deleted the codex/concurrent-rpcs-stateful-serialization branch April 28, 2026 19:23
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 28, 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.

3 participants