Skip to content

Add StreamSession passive subscribe tests and docs#31

Merged
ajit-zer07 merged 1 commit intomainfrom
subscribe-session
Apr 21, 2026
Merged

Add StreamSession passive subscribe tests and docs#31
ajit-zer07 merged 1 commit intomainfrom
subscribe-session

Conversation

@ajit-zer07
Copy link
Copy Markdown
Contributor

Summary

  • Pins macp-proto to 0.1.2 from crates.io so CI can build the passive-subscribe code landed earlier on this branch (previously a local path dep that CI cannot resolve).
  • Adds unit and integration test coverage for the RFC-MACP-0006-A1 StreamSession passive subscribe flow introduced in src/{server,runtime,log_store}.rs.
  • Updates docs/API.md, docs/sdk-guide.md, docs/testing.md, and README.md to describe the subscribe-only frame contract, authorization rules, and after_sequence
    semantics.

What changed

Dependency

  • Cargo.toml / Cargo.lockmacp-proto = "0.1.2" (was a path dep to the spec repo).

Unit tests (src/server.rs, +8)

  • subscribe_replays_session_history_from_zero
  • subscribe_after_sequence_filters_history
  • subscribe_unknown_session_returns_not_found
  • subscribe_non_participant_is_forbidden
  • subscribe_observer_identity_allowed
  • subscribe_initiator_allowed_even_when_not_listed
  • stream_request_with_envelope_and_subscribe_is_rejected
  • subscribe_to_different_session_on_bound_stream_is_rejected

Integration tests (integration_tests/tests/tier1_protocol/test_passive_subscribe.rs, +6)

  • History replay from sequence 0 and after a non-zero offset
  • Unknown session terminates the stream with NotFound
  • Non-participant caller receives an inline FORBIDDEN error frame; stream stays open
  • Late-joiner replays history and then receives a live Evaluation
  • Frame with both envelope and subscribe_session_id rejected with InvalidArgument
  • New dev-dep: tokio-stream = "0.1" (for ReceiverStream on the request side)

Docs

  • docs/API.md — extended StreamSession section with subscribe-only frame semantics and authz
  • docs/sdk-guide.md — added passive subscribe to the StreamSession lifecycle steps
  • docs/testing.md — references the new test_passive_subscribe.rs in the Tier 1 description
  • README.md — new bullet under the StreamSession enabled block

Formatting

  • cargo fmt --all in integration_tests touched two pre-existing files (tier1_jwt.rs, test_validation_gaps.rs). Whitespace only; these drifted because the main CI
    cargo fmt job does not traverse the integration_tests crate.

Test plan

  • cargo fmt --all -- --check — clean in both crates
  • cargo clippy --all-targets -- -D warnings — clean in both crates
  • MACP_MEMORY_ONLY=1 cargo test --all-targets — all runtime unit + integration tests pass
  • MACP_TEST_BINARY=../target/debug/macp-runtime cargo test --test tier1 -- --test-threads=1 — 67/67 pass (was 61)
  • cargo build --release — succeeds
  • cargo audit — exit 0
  • CI passes on this PR (GitHub Actions ci.yml, integration-tests.yml)

  Pin macp-proto to 0.1.2 (published crate) so CI resolves the
  subscribe_session_id + after_sequence fields without needing the
  spec repo co-cloned. Add 8 unit tests in src/server.rs covering
  process_subscribe_frame authz (initiator / participant / observer /
  outsider), history replay, after_sequence filtering, and the
  envelope-vs-subscribe mutual-exclusion rule. Add a Tier 1 integration
  suite (integration_tests/tests/tier1_protocol/test_passive_subscribe.rs,
  6 tests) that drives the real gRPC bidi stream: replay from zero,
  replay with offset, unknown-session termination, non-participant
  inline FORBIDDEN, late-joiner replay-then-live, and invalid mixed
  frames. Document the feature in docs/API.md, docs/sdk-guide.md,
  docs/testing.md, and README.md.
@ajit-zer07 ajit-zer07 merged commit aac7348 into main Apr 21, 2026
9 checks passed
@ajit-zer07 ajit-zer07 deleted the subscribe-session branch April 21, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant