Skip to content

Add SSE parser coverage, StreamHandle lifecycle tests, and production streaming_client example - #149

Merged
MisterVVP merged 6 commits into
dev-add-sse-streaming-support-to-clientsfrom
dev-add-coverage-and-production-streaming-examples
Jul 16, 2026
Merged

MisterVVP merged 6 commits into
dev-add-sse-streaming-support-to-clientsfrom
dev-add-coverage-and-production-streaming-examples

Conversation

@MisterVVP

@MisterVVP MisterVVP commented Jul 14, 2026 •

Copy link
Copy Markdown
Owner

Motivation

  • Close remaining coverage and example gaps for streaming (SSE parsing, StreamHandle lifecycle, and production default-client usage) so the HTTP+JSON and JSON-RPC streaming implementations have deterministic tests and a runnable example.
  • Provide a production-quality example that demonstrates HttpJsonTransport::CreateDefault(...) and JsonRpcTransport::CreateDefault(...) usage with bounded waits and explicit cancellation semantics.

Description

  • Added extensive SSE parser unit tests in tests/unit/sse_parser_test.cpp covering complete events, every-byte splits, multi-event chunks, CRLF framing, data: spacing variants, multiline data:, comments/heartbeats, ignored id:/retry:, empty chunks, finalization, malformed fields, missing separators, callback failure propagation, and empty-stream finalization.
  • Added transport-neutral StreamHandle lifecycle regression tests in tests/unit/stream_handle_lifecycle_test.cpp covering IsActive(), idempotent Cancel(), double-cancel safety, destruction cancellation/join behavior, at-most-once completion, and mutual exclusion of error/completion.
  • Reworked the public example examples/apps/streaming_client/main.cpp to use production default HTTP+JSON and JSON-RPC transports, add a CLI (--transport, --endpoint, --operation, --task-id, --timeout-ms, --cancel-after-first-event), bounded observer waits, and deterministic cancellation behavior.
  • Updated example documentation examples/apps/streaming_client/README.md and docs/streaming-usage.md with build/run instructions and example commands, and updated the example runner scripts/run_examples.sh to smoke-test streaming_client via --help to avoid requiring a live server in smoke runs.
  • Registered the new test target in tests/CMakeLists.txt.

@MisterVVP MisterVVP added the codex Automatic label added by codex agent. Should not be used label Jul 14, 2026 — with ChatGPT Codex Connector
@MisterVVP
MisterVVP marked this pull request as draft July 14, 2026 16:19
@MisterVVP MisterVVP added AI agent AI agent contribution and removed codex Automatic label added by codex agent. Should not be used labels Jul 14, 2026
@MisterVVP MisterVVP self-assigned this Jul 14, 2026
@MisterVVP

Copy link
Copy Markdown
Owner Author

@codex review this pr

@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: 90e2f85a00

ℹ️ 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 examples/apps/streaming_client/main.cpp Resolved
Comment thread scripts/run_http_sse_interop.sh Resolved
Comment thread examples/apps/streaming_client/main.cpp Resolved
### Motivation
- Close remaining SSE streaming test gaps by adding subscribe and
cancellation scenarios for HTTP+JSON and JSON-RPC using production
default transports.
- Add deterministic low-level libcurl streaming tests to validate
metadata/chunk ordering, fragmentation, cancellation, timeout, and
handler-failure propagation.
- Harden StreamHandle lifecycle semantics so cancellation from observer
callbacks cannot deadlock the worker thread.

### Description
- Extend the C++ SUT functional script to run send, subscribe, and
cancel flows for both HTTP+JSON and JSON-RPC against the TCK SUT using
`HttpJsonTransport::CreateDefault(...)` and
`JsonRpcTransport::CreateDefault(...)` (modified
`scripts/run_cpp_sut_streaming_functional.sh`).
- Fix a self-join defect in `StreamHandle::Cancel()` by skipping
`join()` when `Cancel()` is invoked on the worker thread itself (change
in `src/client/client.cpp`).
- Add/extend interop and unit tests: JSON-RPC streaming-envelope
negative cases and incomplete final SSE behavior
(`tests/interop/http_streaming_gap_test.cpp`), low-level libcurl
`StreamRequest` coverage including fragmentation, metadata-before-chunk,
handler failures, timeout and connection failure
(`tests/unit/http_client_test.cpp`), and StreamHandle lifecycle edge
cases including cancellation-from-OnEvent and no-callbacks-after-cancel
(`tests/unit/stream_handle_lifecycle_test.cpp`).
- Improve the interop client to support seeding a non-terminal task,
subscribing, driving a terminal update, and verifying cancellation
behavior in a deterministic way
(`tests/interop/http_sse_interop_client.cpp`).

### Testing
- Ran formatter and full build: `clang-format --dry-run --Werror ...`
and `cmake` / `cmake --build`; build succeeded.
- Ran targeted unit and integration checks:
`./build/tests/http_client_test --gtest_filter='*Stream*'`,
`./build/tests/stream_handle_lifecycle_test`, and the new
`http_streaming_gap_test`; all added/modified tests passed locally.
- Exercised HTTP SSE interop scenarios and C++ SUT matrix end-to-end:
`./scripts/run_http_sse_interop.sh` and
`./scripts/run_cpp_sut_streaming_functional.sh`, which started `tck_sut`
and validated send, subscribe, and cancellation for both transports.
- Executed repository validation: `./scripts/verify_changes.sh` (format,
build, tests, targeted `clang-tidy` fixes applied to touched test
files); the verification run completed with tests passing after fixing
readability issues in the touched tests.
…-RPC fixture validation (#152)

### Motivation
- Align `streaming_client` example docs and commands with the repository
example runner and actual binary layout so users can build and run the
example exactly as written.
- Ensure `SendMessage` requests created by the example always include a
unique non-empty `message_id` and only include a `task_id` when
explicitly provided by the user.
- Centralize CLI flag names to avoid magic strings and reduce
maintenance surface.
- Harden the JSON-RPC SSE fixture used by interop tests to reject
unexpected methods and malformed parameters and add deterministic
negative checks.

### Description
- Update `examples/apps/streaming_client/README.md` to use the example
runner build command and the generated binary path as
`./scripts/run_examples.sh build-example streaming_client` and
`./build-example-streaming_client/a2a_example --help`, and update all
usage examples to call the actual binary path.
- Replace literal CLI flag strings with namespace-scope `constexpr`
constants (for `--help`, `--transport`, `--endpoint`, `--operation`,
`--task-id`, `--timeout-ms`, `--cancel-after-first-event`) and reuse
them in `PrintUsage()` and `ParseOptions()` in
`examples/apps/streaming_client/main.cpp`.
- Remove the example's default `task_id` for sends and add
deterministic, in-process `message_id` generation using a prefix +
timestamp + atomic sequence in `MakeMessageId()`, and set `task_id` in
the `SendMessageRequest` only when the user supplied `--task-id`.
- Update `scripts/interop/python_http_sse_fixture.py` to accept only
`a2a.sendStreamingMessage` and `a2a.subscribeToTask`, validate
`params.message.messageId` (non-empty string) for send and `params.id`
(non-empty string) for subscribe, and return HTTP 400 on unexpected
method or invalid parameters.
- Add deterministic negative interop checks to
`scripts/run_http_sse_interop.sh` that POST malformed/incorrect JSON-RPC
payloads and assert HTTP 400 responses.
- Mark `scripts/run_http_sse_interop.sh` and
`scripts/run_cpp_sut_streaming_functional.sh` executable so they can be
invoked directly.
@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. You're on a roll.

Reviewed commit: fc0e0414f1

ℹ️ 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 July 16, 2026 09:34
@MisterVVP
MisterVVP merged commit 5ce4d9c into dev-add-sse-streaming-support-to-clients Jul 16, 2026
37 of 39 checks passed
@MisterVVP
MisterVVP deleted the dev-add-coverage-and-production-streaming-examples branch July 16, 2026 09:34
MisterVVP added a commit that referenced this pull request Jul 19, 2026
… streaming_client example (#149)

### Motivation
- Close remaining coverage and example gaps for streaming (SSE parsing,
StreamHandle lifecycle, and production default-client usage) so the
HTTP+JSON and JSON-RPC streaming implementations have deterministic
tests and a runnable example.
- Provide a production-quality example that demonstrates
`HttpJsonTransport::CreateDefault(...)` and
`JsonRpcTransport::CreateDefault(...)` usage with bounded waits and
explicit cancellation semantics.

### Description
- Added extensive SSE parser unit tests in
`tests/unit/sse_parser_test.cpp` covering complete events, every-byte
splits, multi-event chunks, CRLF framing, `data:` spacing variants,
multiline `data:`, comments/heartbeats, ignored `id:`/`retry:`, empty
chunks, finalization, malformed fields, missing separators, callback
failure propagation, and empty-stream finalization.
- Added transport-neutral `StreamHandle` lifecycle regression tests in
`tests/unit/stream_handle_lifecycle_test.cpp` covering `IsActive()`,
idempotent `Cancel()`, double-cancel safety, destruction
cancellation/join behavior, at-most-once completion, and mutual
exclusion of error/completion.
- Reworked the public example `examples/apps/streaming_client/main.cpp`
to use production default HTTP+JSON and JSON-RPC transports, add a CLI
(`--transport`, `--endpoint`, `--operation`, `--task-id`,
`--timeout-ms`, `--cancel-after-first-event`), bounded observer waits,
and deterministic cancellation behavior.
- Updated example documentation
`examples/apps/streaming_client/README.md` and `docs/streaming-usage.md`
with build/run instructions and example commands, and updated the
example runner `scripts/run_examples.sh` to smoke-test
`streaming_client` via `--help` to avoid requiring a live server in
smoke runs.
- Registered the new test target in `tests/CMakeLists.txt`.

---------

Co-authored-by: Vladimir Pavlov <[email protected]>
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