Skip to content

feat(server): complete opt-in async unary execution and cancellation - #318

Merged
MisterVVP merged 10 commits into
release/v0.6.0from
feat/async-server
Oct 31, 2026
Merged

MisterVVP merged 10 commits into
release/v0.6.0from
feat/async-server

Conversation

@MisterVVP

@MisterVVP MisterVVP commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #268.

Completes opt-in asynchronous unary server execution for v0.6.0. Applications implement CoroutineAgentExecutor with Boost.Asio C++20 awaitable<Result<T>> methods and supply an Asio executor to AsyncDispatcher. Native AsyncGrpcServerTransport connects that engine to gRPC unary reactors without waiting for backend completion on a reactor thread or allocating one SDK worker per pending request.

The callback-based async application executor and its Asio bridge have been removed. AsyncDispatcher directly awaits CoroutineAgentExecutor methods. Native gRPC reactor callbacks, transport completion handlers, and cancellation observers remain at integration boundaries. Existing synchronous AgentExecutor, Dispatcher, transports, and streaming registration remain source-compatible and available without Boost.

Architecture and lifecycle

  • Transport-neutral request metadata, cancellation, deadlines, and terminal arbitration live in a2a::server::engine. The application receives an owned execution context; first-terminal-transition precedence and exactly-once completion remain authoritative through late backend cleanup.
  • Eight application unary operations use typed coroutine results, including void deletion. Extended agent-card retrieval uses the shared provider, completing all nine unary dispatcher operations.
  • Synchronous and coroutine dispatch share routing, payload validation, authorization, history projection, and interceptor policies. An internal session keeps each request's authenticated principal separate from pipeline configuration. Before hooks run in registration order and after hooks in reverse order. Existing synchronous exception propagation is preserved; async finalization contains after-hook exceptions.
  • RAII admission reservations distinguish logically active requests from pending coroutine cleanup. Cancellation releases active capacity before transport completion, while pending capacity stays reserved until physical cleanup; construction and initial scheduling failures release their reservations.
  • Both gRPC transports share unary request/response conversion, metadata/auth and extension validation, task-list conversion, error/status mapping, and status-details serialization. Reactor ownership, cancellation, and streaming remain with their transports. Existing operation-specific error diagnostics are preserved.
  • Applications can supply their own Asio executor or use the optional AsyncRuntime owner, which runs a fixed-size Boost.Asio thread pool. The owning application shuts down and drains the runtime; suspended frames retain their application and pipeline until cleanup completes. Cancellation remains cooperative.
  • The optional BlockingExecutorAdapter exposes a synchronous, thread-safe AgentExecutor through the coroutine contract. Its Boost.Asio backend pool has explicit worker and queued-plus-running capacity limits. It calls application operations directly without nested dispatch. Cancellation completes the transport logically while running blocking calls retain their capacity until physical cleanup. This is bounded worker adaptation, not nonblocking network or database I/O, and does not restore the removed callback executor API.
  • The optional a2a::asio target requires Boost 1.92 or newer and C++20 standard-library cancellation. Boost's license and notices are included; the SDK remains Apache-2.0. CI includes feature-enabled and feature-disabled builds and the previously fixed Windows/macOS compatibility paths.

Conformance setups and limits

The existing tck_sut retains synchronous execution, streaming, and all three transports. The separate tck_async_sut uses the coroutine engine and registers SDK transports directly, sharing application fixtures, stores, policies, providers, and listener infrastructure with the synchronous setup.

The async setup currently enables gRPC only. HTTP serves agent-card discovery/caching, and JSON-RPC/HTTP+JSON operation routes are unavailable. Unsupported transport selections fail at startup; the card advertises only enabled capabilities. A small awaitable bridge moves blocking fixture application/store operations onto the existing bounded backend queue and delivers results on the awaiting executor. This does not provide async database or outbound network I/O.

Async HTTP scheduling (#270), streaming (#169), outbound clients (#269), and async database stores (#266) remain separate work. Downstream registration, ownership, supported-platform guidance, installed-consumer examples, and reproducible sync-versus-async thread/latency evidence are documented under book/src/server/.

Validation

The local results below were recorded during implementation. Current-head CI results are linked separately below.

  • Canonical A2A_VERIFY_POSTGRES=1 A2A_VERIFY_BUILD_DIR=build ./scripts/verify_changes.sh: 927 registered tests, zero failures; two expected TLS-without-SUT skips. Includes native gRPC lifecycle/race cases, synchronous transports, PostgreSQL, installed consumers, examples, and fixture runtime tests.
  • Exact CI formatting and explicit ./scripts/run_clang_tidy.sh build: passed with Clang 19. The local lint cache keys successful analyses by tool/configuration, compile commands, and translation-unit dependency content. Ubuntu Clang 19 / GTest 1.14 readability and complexity checks also pass.
  • Eleven additional regression tests cover separate authentication sessions, after-hook exception policies, request ownership and typed/list/void response conversion, mismatched payloads, independent active/pending admission, and fixture result/error/executor delivery.
  • ThreadSanitizer: 80 focused dispatch, fixture, conversion, and session tests pass without suppressions.
  • Follow-up 523240c: the chunk-callback shutdown test now holds the SSE stream open and verifies cancellation, eliminating the EOF/shutdown race in its success assertion. The affected 30-test HTTP TSAN suite and 200 repeated executions passed locally. Canonical validation, explicit lint, formatting, TCK, and performance smoke also passed. The complete CI ThreadSanitizer profile has passed on the current head.
  • Official TCK start/run/stop flow on in-memory and PostgreSQL stores: synchronous three-transport setup 249 passed / 16 skipped per store; async gRPC setup 68 passed / 197 skipped per store. Zero executable failures across all four runs.
  • Required gRPC + HTTP/JSON performance smoke: 54 scenarios, zero errors. Before/after immediate-dispatch benchmark samples remain within observed run-to-run variation on the shared runner.
  • mdbook build book: passed. Boost dependency and vcpkg manifest/configuration changes are included; Python tooling pip-audit reports no known vulnerabilities. This is not a complete automated C++ dependency advisory audit.

All six pull-request workflows have completed successfully on the current head, d47aa3435b: CI, TCK Conformance, CodeQL, Docs, Tutorials, and Commit messages.

The previously approved TCK registry-coverage baseline remains explicit: synchronous reports show 80.9% MUST / 80.0% overall coverage; the narrower async gRPC reports show 59.8% MUST / 61.5% overall. Upstream report tables group untested requirements under “Failed”; no executed requirement fails. Passing executable tests does not claim complete registered-requirement coverage.

Authorship and AI usage

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

Checklist

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

## Summary

Introduce a transport-independent request lifecycle for pending
asynchronous server operations, so applications can retain request
metadata and distinguish client cancellation, deadline expiry, shutdown,
success and application failure.

The complete request execution module uses `a2a::server::engine`: public
API at `include/a2a/server/engine/request_execution.h`, with
implementation and state in `src/server/engine/`.

Implements **PR 1 of #268**. This PR leaves #268 open and keeps
executor, dispatcher, transport, streaming and outbound-client
integration for their planned follow-ups.

- Add a non-copyable `RequestExecution` owner and copyable
`RequestExecutionContext` with an immutable snapshot of the existing
`RequestContext`, monotonic deadline and C++20 cancellation token.
- Choose exactly one terminal outcome atomically. Completion checks
deadline expiry; cancellation observers run inline without an SDK mutex
and retain safe state during reentrancy/owner destruction. Pending owner
destruction signals shutdown.
- Require the caller's scheduler to drive deadline notification. The API
starts no timer or worker thread and leaves synchronous APIs unchanged.
- Add 15 deterministic lifecycle tests covering metadata lifetime,
pre-cancellation, late/removed observers, in-progress observer
destruction, completion/cancellation races, deadline boundaries,
shutdown and releasing the final owner from an observer. Include this
optional target in the TSAN runner when available.
- Probe C++20 cancellation support and export
`A2A_HAS_REQUEST_EXECUTION`; omit the new implementation/tests on older
standard libraries while preserving synchronous builds. Document
availability, ownership, precedence, scheduling and observer lifetime
guarantees in the server book.

## Authorship and AI usage

- [ ] Contains substantive content written by a human
- [x] Contains substantive content generated by an AI agent

## Testing

Current-head validation: the engine target builds, all 15 lifecycle
tests pass, and formatting, targeted clang-tidy, and `mdbook build book`
pass. The full SDK, TCK, sanitizer, and performance suites were not
repeated for this final namespace/file relocation.

Earlier full Linux validation, before the final namespace/file
relocation:

- Clean Debug SDK build and CTest: zero failures across 790 cases (two
TLS fixture skips).
- 15 lifecycle tests pass with ThreadSanitizer and
AddressSanitizer/UndefinedBehaviorSanitizer (`detect_leaks=0`;
LeakSanitizer is restricted in this environment).
- Repository formatting checks and `mdbook build book` pass.
- Native cancellation capability probe passes; the forced-unavailable
CMake graph excludes the new source/test and exports
`A2A_HAS_REQUEST_EXECUTION=0`. TSAN target selection and shell syntax
are verified in both configurations.
- Unmodified upstream TCK `d4d6fae7887f88ef607fb461c13e3b0e1802f19b`
passes across gRPC, JSON-RPC and HTTP+JSON on both in-memory and
PostgreSQL stores: 249 passed, 16 conditional skips per store. MUST
registry coverage remains **80.9%**, matching the documented release
baseline in `book/src/compatibility/conformance.md`; 21 MUST
requirements have no upstream executable fixtures. This is not a claim
of 100% TCK compliance.
- Python validation-tool dependency audit reports no known
vulnerabilities. The native OSV scan was attempted but its API endpoint
is denied by the environment network policy; SDK dependency manifests
are unchanged.
- Performance smoke: gRPC/HTTP+JSON, in-memory store, two requests at
concurrency one, no warmup/duration; 54 result rows and zero errors
(Debug SDK build).
- `./scripts/run_clang_tidy.sh build` and `A2A_VERIFY_POSTGRES=1
A2A_VERIFY_BUILD_DIR=build ./scripts/verify_changes.sh` both exit 0. The
exact CI `clang-format --dry-run --Werror` mechanism also passes (Clang
19).

Local lifecycle benchmark (GCC 15, `-O2`, median of 5 samples of 100,000
operations): metadata snapshot 72.7 ns/op; snapshot plus
lifecycle/context/completion 159.1 ns/op. These measurements describe
the new opt-in primitive, not network I/O or end-to-end async execution.

## Checklist

- [x] `./scripts/verify_changes.sh` passed locally before the final
namespace/file relocation; scoped checks passed for the latest change
- [x] Docs updated if behavior changed
## Summary

Implements **Phase 2 / PR 2 of #268** against `feat/async-server`.
Applications can initiate unary work and return immediately, then
complete it from any thread through the new opt-in
`a2a::server::engine::AsyncAgentExecutor` and `AsyncDispatcher`.

- Supports SendMessage, GetTask, ListTasks, CancelTask, push-config
create/get/list/delete, and extended agent cards through the existing
provider.
- Extracts one shared typed operation router and pipeline for sync/async
payload checks, security, interceptor ordering, agent-card retrieval,
and history projection. Required extensions use the existing validator.
Public synchronous APIs remain source-compatible; each dispatch
snapshots its interceptor list.
- Uses a fixed worker pool and bounded in-flight admission. Pending
application work holds no SDK worker. Executor initiation, hooks,
policies/providers, and transport completion run on workers. The
existing inline, non-blocking stop-observer contract is retained.
- Delivers one terminal completion and one reverse-order AfterDispatch
pass, including errors/cancellation. Completion receives an owned
lifecycle context, so it is safe even before Dispatch returns its
cancellation handle. Deadlines remain transport-driven, with
start/completion checks.
- Handles shutdown, late/duplicate replies, executor release, and
dispatcher destruction from completion/cancellation observers. The
existing security/store and agent-card provider facilities run on
bounded workers; they retain their synchronous contracts.

Adds API/threading documentation and immediate-result microbenchmarks.
Native transport registration remains PR 3; #268 stays open.

## Authorship and AI usage

- [ ] Contains substantive content written by a human
- [x] Contains substantive content generated by an AI agent

## Testing

- `A2A_VERIFY_POSTGRES=1 A2A_VERIFY_BUILD_DIR=build
./scripts/verify_changes.sh` — passed; **839 tests**.
- Exact `./scripts/run_clang_tidy.sh build` and CI `clang-format
--dry-run --Werror` mechanism — passed. New benchmark also passed
targeted clang-tidy.
- **49 fake-transport/component tests**, covering every operation,
errors, metadata, security/history, extensions, admission, lifecycle
races, and shutdown; 50 consecutive runs passed before the final
test-guard cleanup.
- TCK via `run_tck_sut.sh` / `run_tck_mandatory.sh` / `stop_tck_sut.sh`,
with grpc/jsonrpc/http_json: **249 passed, 16 conditional skips on each
of PostgreSQL and in-memory stores**.
- `mdbook build book` — passed.
- Required performance smoke: **54 rows, 0 errors**.
- Python dependency audit — no known vulnerabilities. Native OSV
scanning was attempted but this environment blocks `api.osv.dev`; SDK
dependency versions are unchanged.

The TCK retains the **previously approved baseline from PR #315**:
**80.9% MUST / 80.0% overall coverage**, with 21 registered MUST
requirements lacking upstream tests. All executable tests passed; this
is not a claim of 100% specification compliance. Upstream TCK revision:
`d4d6fae7887f88ef607fb461c13e3b0e1802f19b`.

## Performance evidence

RelWithDebInfo, GCC 15, identical immediate in-memory GetTask response,
one outstanding request, no interceptors/security; five repetitions with
a 0.2 s minimum. The base comparison links the original dispatcher from
`44d927b` with the same fixture and dependencies.

| Path | Median wall time |
| --- | ---: |
| Original synchronous dispatcher | 0.408 µs |
| Shared synchronous pipeline | 0.631 µs |
| Async dispatcher, one SDK worker | 19.690 µs |

The shared sync path adds approximately **0.22 µs (+55%)** in this
microbenchmark, recorded explicitly for review. Async timing includes
admission, lifecycle, queue scheduling and the benchmark's future-based
reply handoff. These measurements cover immediate-result overhead;
broader concurrency/latency evidence remains PR 4. The fake transport
tests independently prove 32 pending operations can initiate on at most
two SDK workers.

## Checklist

- [x] `./scripts/verify_changes.sh` passed locally
- [x] Docs updated if behavior changed
…#317)

## Summary

Completes the remaining PR 3 and PR 4 scope of #268 in one PR, targeting
`feat/async-server`, as requested.

Adds opt-in `AsyncGrpcServerTransport` for all nine unary RPCs. It
connects the existing async engine to native gRPC callbacks, copies
metadata/auth, propagates deadlines and cancellation, and queues
application execution, stop observers, interceptors, and response
finalization on the bounded SDK worker pool. Shared helpers preserve
synchronous validation, status/ErrorInfo mapping, extension trailers,
and ListTasks conversion.

Adds explicit service shutdown, native lifecycle/concurrency tests, an
installed-package consumer example, a platform availability guide, async
unary TCK profiles for both stores, and reproducible sync/async thread
and latency evidence. Existing synchronous registration remains
available. Streaming, HTTP scheduling, outbound clients, and async
database I/O remain outside #268.

Older gRPC releases receive the exported stable-callback API opt-in.
Installed-package dependency discovery resolves gRPC before a Protobuf
fallback, avoiding partial target exports. Request envelopes initialize
the operation directly before payload conversion, and the
server-deadline test disables the competing client timer.

The test and measurement clients use one explicitly polled completion
queue per fixture, keeping client thread counts fixed across both
service paths and supporting legacy Windows gRPC. Installed-consumer
validation generates only the SDK configuration installed for the test.
Windows scratch cleanup is best-effort when build tools retain directory
handles; installation, build, and smoke-test errors still propagate.
Lifecycle assertions are grouped into focused helpers so Ubuntu's GTest
1.14 macro expansions remain within the lint complexity limit.

## Evidence

With two SDK workers and controller-held pending replies, 32/128
concurrent async requests used two application threads in both cases;
the equivalent synchronous path used 32/128. Representative loopback
p50/p95 values, configurations, limitations, and reproduction commands
are in the new guide. The TCK adapter executes the existing synchronous
fixture on bounded workers and is explicitly documented as a
compatibility fixture.

## Testing

- Canonical `A2A_VERIFY_POSTGRES=1 A2A_VERIFY_BUILD_DIR=build
./scripts/verify_changes.sh`: 880 tests passed.
- Repository formatter, exact CI dry-run formatting, and
`./scripts/run_clang_tidy.sh build`: passed; lint uses a local cache
keyed by translation-unit dependencies and tool/configuration inputs.
- ASan/UBSan: 84 native/async-engine tests passed. ThreadSanitizer: 65
lifecycle/async-engine tests passed.
- Native deadline-versus-completion boundary race: application replies
scheduled before, at, and after the server deadline; verifies
exactly-once completion/AfterDispatch and ignores duplicate replies
after gRPC teardown and SDK destruction. Passed 30 repetitions (90
RPCs), plus 10 repetitions under ASan/UBSan.
- Native cancellation/deadline/admission race cases: 30 repetitions
passed; the isolated server-deadline case also passed 50 consecutive
runs.
- Clang-tidy 18 with GTest 1.14 system headers passed for the dispatcher
tests and native client fixture; the original complexity diagnostics
were reproduced before the fix. Isolated Protobuf dependency-order and
multi-config installed-consumer checks reproduce the old failures and
pass with the fixes.
- Installed SDK consumer and native example smoke passed;
unsupported-library fallback returns CTest skip code 77.
- Official TCK start/run/stop flow: synchronous in-memory and PostgreSQL
each 249 passed / 16 skipped; native async gRPC each 68 passed / 197
skipped due to transport/capability selection.
- Performance smoke: 54 cases, zero errors. mdBook build and
Python/workflow syntax checks passed.
- `pip-audit`: no known vulnerabilities. Native OSV scan attempted but
blocked by the environment's HTTP 403 policy for `api.osv.dev`; no
dependency versions changed.

The previously authorized TCK baseline exception is retained: the
upstream registry reports 80.9% MUST coverage (80.0% overall) because 21
MUST requirements have no upstream tests. All executable tests passed;
this is not a claim of complete registered-requirement coverage. Local
Linux GCC validation and all required CI checks, including Windows,
macOS, sanitizers, conformance, performance, and CodeQL, passed on
`768fde3`.

## Authorship and AI usage

- [ ] Contains substantive content written by a human
- [x] Contains substantive content generated by an AI agent

## Checklist

- [x] `./scripts/verify_changes.sh` passed locally
- [x] Docs updated if behavior changed

@MisterVVP ready for your review.
@MisterVVP MisterVVP added the AI agent AI agent contribution label Oct 28, 2026 — with ChatGPT Codex Connector

Copy link
Copy Markdown
Owner Author

@codex review

Please perform the final review of the complete #268 implementation against main, covering all three phases brought together from #315, #316, and #317. Check the issue's acceptance criteria, synchronous source compatibility and protocol parity, request lifetime and exactly-once completion/AfterDispatch, cancellation/deadline races and late replies, shutdown safety, bounded SDK worker growth, and platform/installed-consumer compatibility. The PR description records validation evidence and the approved upstream TCK coverage baseline exception.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-30T21:37:29.971736Z d47aa34 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.

@MisterVVP MisterVVP self-assigned this Oct 28, 2026
@MisterVVP MisterVVP added documentation Improvements or additions to documentation enhancement New feature or request performance Performance improvement related tasks based on benchmark results. Performance tests changes. labels Oct 28, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: c7847886ec

ℹ️ 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 changed the base branch from main to release/v0.6.0 October 29, 2026 07:25

@MisterVVP MisterVVP left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Ideally we want a single TCK with async i/o rather that having per transport TCK for async i/o. Can we refactor our approach so we build one TCK and tests for async i/o with only gRPC enabled within this PR? So this way we can expand on it.

Pls answer PR comments and explain reasoning. Also avoid writing unnecessary inline code comments

Comment thread tests/sut/sut_runtime.cpp Resolved
Comment thread tests/sut/sut_runtime.cpp Resolved
Comment thread tests/sut/blocking_sut_executor.h Resolved
Comment thread src/server/transport/grpc_dispatch.cpp Resolved

Copy link
Copy Markdown
Owner Author

@codex review

Please review b8a1b69 against release/v0.6.0, including the maintainer's architectural feedback. The synchronous three-transport TCK remains intact; tck_async_sut is one shared async setup with only gRPC enabled initially. Both setups share application fixtures and policies, register SDK services directly, and avoid nested synchronous dispatch. The async fixture uses bounded backend work for existing synchronous store APIs. The gRPC mapping, wire encoding, metadata, and task-conversion components now have cohesive source/header pairs and focused tests. Local validation passed: canonical 893-test suite, exact formatting/lint, CI-compatible clang-tidy 18/GTest 1.14, ASan/UBSan (32 focused tests), ThreadSanitizer (44 selected tests), all four TCK setup/store combinations, performance smoke (54 cases, zero errors), and docs. Review-thread explanations and the PR description are updated; the approved upstream TCK coverage baseline remains explicit.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: b8a1b698fc

ℹ️ 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 marked this pull request as draft October 29, 2026 09:15
MisterVVP and others added 3 commits October 29, 2026 22:13
)

## 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
- [x] Contains substantive content generated by an AI agent

## Checklist

- [x] `./scripts/verify_changes.sh` passed locally
- [x] Docs updated if behavior changed
## Problem and resulting behavior

DevEx follow-up to #268 and #318. SDK consumers currently have to
implement a bounded work queue, an awaitable bridge, eight forwarding
methods, and runtime lifetime management to reuse a blocking executor
with the coroutine engine. This adds 15 files to the TCK consumer.

The SDK now provides three composable conveniences:

- `engine::BlockingExecutorAdapter`: an explicit compatibility adapter
for an owned, thread-safe `AgentExecutor`. It bounds queued plus running
work, checks cancellation/deadlines before backend execution, preserves
typed results/errors, contains backend exceptions, and delivers
completion on the awaiting executor.
- `engine::AsyncRuntime`: an optional owner for a fixed Asio pool and
`AsyncDispatcher`, with separate nonblocking shutdown and draining join.
Existing caller-supplied Asio executors remain supported. Explicit joins
from an owner's worker are rejected instead of deadlocking.
- `ServerBindings`: owns SDK transport registrations and their route
references. Sync construction registers all three transports; async
construction registers native gRPC unary operations and HTTP agent-card
discovery. Hosts retain ownership of listeners, credentials, and
signals. Shared extension requirements and configured HTTP paths apply
consistently.

An existing blocking application can use:

```cpp
auto adapted = std::make_shared<engine::BlockingExecutorAdapter>(legacy, limits);
engine::AsyncRuntime runtime(adapted, execution_options);
ServerBindings bindings(runtime.dispatcher(), card, binding_options);
```

Native coroutine applications pass their executor directly to
`AsyncRuntime`. The installed-SDK examples cover both paths and native
gRPC hosting. The new guide documents ownership, admission, shutdown,
and supported bindings.

## SUT simplification

Measured against #318's release base (`1ac17b5`):

| Metric | Before | After |
| --- | ---: | ---: |
| Added files under `tests/sut` | 15 | 1 |
| Net added SUT lines | 616 | 61 |

This removes **90.1% of net added SUT code** and 14 extra fixture files.
Test-specific behavior, cards, policies, environment parsing, and
listener hosting remain in the original fixture files. The single async
entrypoint selects the shared setup.

Configured REST and JSON-RPC paths now use the same shared normalizer in
the transports, binding route matchers, and JSON-RPC root alias. Missing
leading slashes, trailing slashes, empty paths, and root paths retain
the underlying transports' configuration semantics.

## Preservation of #268

The request-lifecycle implementation, coroutine dispatcher, and native
gRPC execution implementation are unchanged. Existing typed operations,
extended-card providers, shared validation/interceptors/security,
deadlines, exactly-once completion, cancellation precedence, and
active/physical-cleanup admission semantics remain covered. The native
gRPC lifecycle tests now also exercise the convenience composition.

Synchronous execution and streaming remain available across all three
transports, including feature-disabled builds without Boost or C++20
cancellation. The async setup retains gRPC unary execution plus HTTP
discovery. Blocking adaptation uses a fixed bounded pool and remains
explicit about blocking backend I/O.

Validation exposed an existing timing-dependent sync streaming test. It
now waits for the backend's pending read before cancelling, and
synchronizes its fixture cancellation notification with that wait.
Production streaming code is unchanged. Both cancellation cases passed
50 repetitions after the fixture fix.

## Platform build fixes

- Protect SDK executor declarations, consumer headers, and the
implementation after late Boost includes from Win32's `SendMessage` →
`SendMessageA/W` macro alias. A portable compile regression exercises
affected header orders with Asio enabled and disabled; a late-include
reproducer fails before the fix and compiles afterward.
- Normalize the generated gRPC header and source after generation,
clearing `SendMessage` after dependency includes so the static library
and SDK agree on the stub/service symbol names. The regression also
instantiates both generated service types to check vtable linkage and
avoids macro-redefinition warnings.
- The cancelled `macos-build` never started: GitHub reported
hosted-runner acquisition/internal errors and ARM capacity constraints.
Move this non-Asio job to the supported `macos-15-intel` pool, retaining
`macos-15` ARM coverage for Asio and independent matrix execution.

## Validation

Latest review follow-up (`0a19974`): focused builds and **85 tests
passed**, including 12 new REST/JSON-RPC path-configuration cases and
existing async bindings tests. Targeted clang-tidy for all changed
implementations and the test file, plus exact CI formatting, passed.
Long verification/TCK/performance checks were not repeated; validation
remains scoped as requested.

Windows linker follow-up (`1b263cc`): focused build and all 44
gRPC/macro tests passed, as did targeted clang-tidy and exact CI
formatting. Injecting the Win32-style macro into generated-code
dependencies reproduces the old missing-symbol linker failure; the
normalized object links and runs successfully. Long
verification/TCK/performance checks were skipped for this follow-up at
the maintainer's request. Full-suite results below are from preceding
commits.

- Canonical PostgreSQL-enabled `./scripts/verify_changes.sh`: 943
registered tests, zero failures; two expected TLS-without-SUT skips.
- Explicit `./scripts/run_clang_tidy.sh build` and exact CI formatting
check: passed. Lint reuses successful analyses by tool/configuration and
source content; reuse for unchanged translation units is checked against
compiler-recorded dependencies.
- Focused ThreadSanitizer: 71 lifecycle, dispatcher, adapter, runtime,
and SUT tests passed without suppressions.
- Feature-disabled build without Boost/cancellation: synchronous SDK/SUT
targets built; 14 focused tests passed.
- Clean installed-SDK consumers: coroutine timer, native async gRPC, and
blocking-executor examples passed.
- Official TCK start/run/stop on both in-memory and PostgreSQL stores:
sync **249 passed / 16 skipped**, async **68 passed / 197 skipped** per
store. Zero executed failures across all four runs.
- Required gRPC + HTTP/JSON performance smoke: **54 scenarios, zero
errors**.
- `mdbook build book`: passed. Python tooling `pip-audit`: no known
vulnerabilities. Dependency manifests are unchanged; this is not a
complete automated C++ dependency advisory audit.

The previously approved TCK registry-coverage baseline is preserved:
synchronous MUST 80.9% / overall 80.0%; async gRPC MUST 59.8% / overall
61.5%. Passing executable tests does not claim complete
registered-requirement coverage.

Platform CI will run on this PR; earlier heads' results do not replace
those checks.

## Authorship and AI usage

- [ ] Contains substantive content written by a human
- [x] Contains substantive content generated by an AI agent
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: d47aa3435b

ℹ️ 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 marked this pull request as ready for review October 31, 2026 10:09
@MisterVVP
MisterVVP merged commit 43390e1 into release/v0.6.0 Oct 31, 2026
23 checks passed
@MisterVVP
MisterVVP deleted the feat/async-server branch October 31, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI agent AI agent contribution documentation Improvements or additions to documentation enhancement New feature or request performance Performance improvement related tasks based on benchmark results. Performance tests changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: Add opt-in async unary server execution and cancellation

1 participant