Skip to content

feat(server): simplify consumer setup with runtime helpers - #320

Merged
MisterVVP merged 4 commits into
feat/async-serverfrom
feat/async-server-devex
Oct 30, 2026
Merged

MisterVVP merged 4 commits into
feat/async-serverfrom
feat/async-server-devex

Conversation

@MisterVVP

@MisterVVP MisterVVP commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

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:

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
  • Contains substantive content generated by an AI agent

@MisterVVP MisterVVP added AI agent AI agent contribution documentation Improvements or additions to documentation enhancement New feature or request labels Oct 30, 2026 — with ChatGPT Codex Connector
@MisterVVP MisterVVP self-assigned this Oct 30, 2026
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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:20:03.323807Z 0a19974 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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: 1b263cca6c

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

Copy link
Copy Markdown
Owner Author

@codex review this PR again

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 0a1997431e

ℹ️ 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 d47aa34 into feat/async-server Oct 30, 2026
23 checks passed
@MisterVVP
MisterVVP deleted the feat/async-server-devex branch October 30, 2026 21:33
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant