Skip to content

refactor(server)!: switch async execution to Boost.Asio coroutines - #319

Merged
MisterVVP merged 5 commits into
feat/async-serverfrom
feat/asio-coroutine-executor
Oct 29, 2026
Merged

MisterVVP merged 5 commits into
feat/async-serverfrom
feat/asio-coroutine-executor

Conversation

@MisterVVP

@MisterVVP MisterVVP commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Switch the async server execution API from completion callbacks to Boost.Asio coroutines. AsyncDispatcher now awaits CoroutineAgentExecutor operations directly, including shared validation, interception, authorization, dispatch and response projection. This replaces the callback engine rather than wrapping it.

Targets feat/async-server, continuing #268 / #318.

  • Remove AsyncAgentExecutor, AsioAgentExecutor, and the dispatcher's custom worker queue. All eight executor unary operations return typed boost::asio::awaitable<core::Result<T>>; agent-card providers remain in the dispatcher.
  • Run each request on an application-owned Asio context with a per-request strand. Preserve immediate admission limits, owned metadata, stop-token propagation, deadline arbitration, exactly-once hooks/terminal delivery, and safe late backend completion. max_pending also bounds frames retained after logical cancellation. The completion sink at the gRPC transport boundary remains required by gRPC's callback reactor API.
  • Share typed operation routing with synchronous dispatch without a callback adaptation layer. Keep the synchronous SDK independent of Boost. Async dispatch, its native gRPC transport, examples, tests and benchmarks live in optional a2a::asio, enabled by A2A_ENABLE_ASIO=ON; there is no callback execution fallback.
  • Migrate the async SUT, fixtures, installed consumers, examples and benchmarks to the coroutine engine. Preserve the synchronous three-transport TCK setup and the unified async setup across its transport facades. Native async listening remains gRPC; synchronous fixture/store operations run on bounded backend workers.
  • Fix the macOS Asio build on current gRPC: the client deadline-checking option has been removed upstream. Native deadline tests detect whether it exists and check the terminal signal actually observable by the server, while retaining strict exactly-once and late-result safety checks. Older gRPC still tests an isolated server deadline. The LLVM/libc++ header-ordering fix is retained.
  • Fix an HTTP streaming teardown race uncovered by full validation: retain the process-global pool, join reactors, then drain callback workers before releasing global state. Defer all pool cleanup from reactor threads to avoid cross-shard join/lock cycles as well. Add shutdown and cleanup regression coverage.
  • Defer Windows GoogleTest discovery until CTest runs, after parallel linking and app-local DLL deployment finish. Allow 30 seconds to enumerate the JSON-RPC integration executable, which exceeded CMake's five-second default; actual test execution limits are unchanged.
  • Install checksum-pinned simdjson 4.6.11 in the Linux lint/build profile, matching the locally validated dependency. Ubuntu's 3.0.1 header contains invalid CRTP member lookup rejected by Clang 19. The installer builds and installs successfully; its header matches the local validated header byte-for-byte, and Ubuntu's Clang 19 passes the JSON implementation with it. The SDK minimum stays at simdjson 3.0.
  • Select clang-tidy 19 for Linux CI. Clang 18 incorrectly analyzes a suspended Boost.Asio coroutine as running before its frame is attached; the finding reproduces locally. Keep the analyzer enabled and retain the build compiler matrix.
  • Use Boost 1.92.0, the latest stable release, via the checksum-pinned installer and optional vcpkg Asio feature. Include Boost license notices; the SDK remains Apache-2.0. Exercise coroutine builds in Linux, Windows, macOS, ASan/UBSan and TSan CI.

API migration: derive from CoroutineAgentExecutor, use co_return/co_await, construct AsyncDispatcher(application, scheduler, options), and link a2a::asio. Replace worker_count with a caller-owned execution context, and drain it during shutdown. Coroutine cancellation cannot forcibly interrupt uncooperative backend I/O. Blocking security/store APIs still need bounded workers; coroutine streaming and native async HTTP/JSON-RPC listeners remain follow-up work.

Validation

  • A2A_VERIFY_POSTGRES=1 A2A_VERIFY_BUILD_DIR=build ./scripts/verify_changes.sh: 916 registered tests, no failures, two expected TLS-without-SUT skips; complete source/test lint passes. Asio enabled with Boost 1.92.0.
  • Exact CI formatting check and explicit ./scripts/run_clang_tidy.sh build: exit 0. Changed test translation units also pass Clang 18 / GoogleTest 1.14 complexity checks.
  • Focused coroutine, native-gRPC, SUT and HTTP suites: 142 tests pass under ASan/UBSan with leak detection; the final cleanup/capacity changes were rerun in 45 focused tests. 86 SDK-owned engine/lifecycle tests pass under TSan, plus 45 final HTTP/capacity tests, without suppressions.
  • Simulate current gRPC without the removed client-deadline option: both native deadline cases pass for 10 repetitions, including completion races and late backend results after transport destruction.
  • Official start/run/stop TCK flow with both stores: synchronous three-transport profile 249 passed / 16 skipped per store; coroutine async gRPC profile 68 passed / 197 skipped per store. No executable failures. Final PostgreSQL rerun also passes. Existing upstream registry coverage gaps remain (80.9% synchronous MUST coverage); publication follows the previously approved documented baseline.
  • HTTP cancellation/process teardown: 40 isolated process runs pass. PostgreSQL cross-binding scenarios pass five consecutive runs after the cleanup fix.
  • Required gRPC + HTTP/JSON performance smoke: 54 scenarios, zero errors. Feature-disabled SDK builds with Boost discovery disabled; installed coroutine and native-gRPC consumers pass.
  • mdbook build book, workflow YAML parsing and changed shell-script syntax checks pass. Python dependency pip-audit reports no known vulnerabilities. The Boost archive checksum/license were verified. OSV Scanner does not support this vcpkg manifest, so this is not a complete automated C++ dependency advisory audit.

Controlled native-gRPC evidence (RelWithDebInfo, GCC 15, gRPC 1.51.1, Boost 1.92.0; backend held for 10 ms):

Pending requests Sync application threads Coroutine application threads Sync p50 / p95 Coroutine p50 / p95
32 32 2 14.237 / 14.613 ms 11.273 / 11.361 ms
128 128 2 31.570 / 34.306 ms 14.045 / 14.580 ms

The coroutine process stayed at 13 threads for both request counts; the synchronous process rose from 11 to 42 / 138 threads. This demonstrates bounded application-thread use for a controlled asynchronous backend, not general database throughput. Immediate-dispatch Google Benchmark samples were also recorded; the previous callback-adapter timing is no longer evidence for this replacement design.

Authorship and AI usage

  • Contains substantive content written by a human
  • Contains substantive content generated by an AI agent

Checklist

  • ./scripts/verify_changes.sh passed locally
  • Docs updated if behavior changed

@MisterVVP MisterVVP added the AI agent AI agent contribution label Oct 29, 2026 — with ChatGPT Codex Connector
Await CoroutineAgentExecutor directly on an application-owned Asio context.
Remove the callback executor, adapter and custom dispatcher worker queue;
migrate fixtures, SUT, examples, benchmarks and package consumers.

Preserve terminal arbitration, cancellation, pending-frame bounds and shared
sync routing. Handle modern gRPC deadline APIs in native lifecycle tests.
Fix HTTP reactor teardown and off-thread cleanup races found by validation.
@MisterVVP MisterVVP changed the title feat(server): add Boost.Asio coroutine executors refactor(server)!: switch async execution to Boost.Asio coroutines Oct 29, 2026
Install checksum-pinned simdjson 4.6.11 with Boost for the Clang 19 lint
profile. This matches local validation and avoids Ubuntu 24.04's invalid
simdjson 3.0.1 CRTP lookup without changing the SDK minimum dependency.

Defer Windows GoogleTest enumeration until test time, after linking and
app-local DLL deployment complete. Give JSON-RPC integration discovery
30 seconds without changing test execution timeouts.
@MisterVVP MisterVVP self-assigned this Oct 29, 2026
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T19:52:39.603405Z 0eec5d9 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 0eec5d99e2

ℹ️ 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".

@MisterVVP
MisterVVP merged commit 555dcf7 into feat/async-server Oct 29, 2026
23 checks passed
@MisterVVP
MisterVVP deleted the feat/asio-coroutine-executor branch October 29, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI agent AI agent contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant