Bindu
Bindu copied to clipboard
feat: gRPC Support implementation + minor fixes
Summary
- Problem: gRPC support was partially integrated after branch merges, with auth-path mismatch, startup/runtime breakages, missing transport metadata, uneven gRPC test coverage,
tytype checker failures on dictionary assignments, and overall pytest coverage dropping below the 70% threshold due to missing tests in configuration and utility files. Also, there were some broken test cases missing required arguments. - Why it matters: without these fixes, gRPC mode could fail at runtime, auth could diverge from project standards, PR confidence/reviewability would be low, and the automated CI pipeline would remain blocked by type errors and insufficient code coverage.
- What changed: completed gRPC server/app wiring, aligned gRPC auth to Hydra-based validation, restored gRPC settings + agent-card transport fields, fixed tracing compatibility issue, added gRPC docs, added/updated focused gRPC tests to push coverage past 70%, correctly type hinted dictionaries in
test_grpc_converters.pyusingtyping.castfor thetychecker, fixed broken/missing tests intests/unit/test_config_loader.py,tests/unit/test_agent_token_utils.py, andtests/unit/test_schema_manager.py(including fixingAgentCredentialsmissing arguments andAsyncMockcontext manager setups), added required gRPC dependencies inpyproject.toml(grpcio,protobuf,grpcio-toolsfor dev), and synceduv.lock. - What did NOT change (scope boundary): no storage backend redesign, no scheduler backend redesign, no extension-protocol redesign, no DB schema changes for this PR.
Change Type (select all that apply)
- [x] Bug fix
- [x] Feature
- [ ] Refactor
- [x] Documentation
- [x] Security hardening
- [x] Tests
- [x] Chore/infra
Scope (select all touched areas)
- [x] Server / API endpoints
- [ ] Extensions (DID, x402, etc.)
- [ ] Storage backends
- [ ] Scheduler backends
- [x] Observability / monitoring
- [x] Authentication / authorization
- [ ] CLI / utilities
- [x] Tests
- [x] Documentation
- [ ] CI/CD / infra
Linked Issue/PR
- Closes #67
- Related #99, #130
User-Visible / Behavior Changes
- gRPC transport can be enabled and served alongside existing HTTP/JSON-RPC flow.
- Agent card now advertises gRPC transport metadata when gRPC is enabled.
- gRPC auth follows main-project Hydra validation flow (instead of separate Auth0-style path).
- New gRPC usage guide added in docs and linked from README.
- Default behavior remains unchanged unless gRPC is explicitly enabled.
Security Impact (required)
- New permissions/capabilities? (
Yes/No): Yes (adds gRPC transport capability when enabled) - Secrets/credentials handling changed? (
Yes/No): No (no new secret format/storage introduced) - New/changed network calls? (
Yes/No): Yes (gRPC listener/traffic path when enabled) - Database schema/migration changes? (
Yes/No): No - Authentication/authorization changes? (
Yes/No): Yes (gRPC auth path aligned to Hydra validator) - If any
Yes, explain risk + mitigation:- Risk: new network surface (gRPC) and auth-path changes could allow misconfiguration.
- Mitigation: gRPC is config-gated (opt-in), auth is centralized via existing Hydra path, and targeted unit/integration tests were added for auth/server/core RPC behavior.
Verification
Environment
- OS: Windows
- Python version: 3.12.9
- Storage backend: default local/test backend used by existing test setup
- Scheduler backend: default local/test backend used by existing test setup
Steps to Test
- Activate venv and run gRPC-focused tests.
- Run gRPC coverage command and confirm module coverage is above threshold.
- Run full pre-commit (or repo-required hooks) and verify pass.
- Start beginner example with gRPC enabled and confirm server startup + basic request flow.
Expected Behavior
- gRPC-enabled app starts cleanly, auth interceptor validates tokens through Hydra path, agent card includes gRPC transport metadata, and tests/coverage meet gate.
Actual Behavior
- Verified: targeted and gRPC-focused tests pass; coverage is above 70%; commit/push succeeded after checks; local runtime smoke test passed (
/.well-known/agent.jsonreachable withadditionalInterfacesincludinggrpc://127.0.0.1:50051and gRPCHealthCheckreturned status1/ SERVING).
Evidence (attach at least one)
- [ ] Failing test before + passing after
- [x] Test output / logs
- [ ] Screenshot / recording
- [ ] Performance metrics (if relevant)
$ c:/Users/Nilay/Desktop/Bindu/.venv/Scripts/python.exe -m pytest tests/unit/test_grpc_auth_interceptor.py tests/unit/test_grpc_converters.py tests/unit/test_grpc_core_rpcs.py tests/unit/test_grpc_push_notifications.py tests/unit/test_grpc_server.py tests/integration/test_grpc_integration.py -q -rA
================================ test session starts ================================
platform win32 -- Python 3.12.9, pytest-8.3.5, pluggy-1.5.0
rootdir: C:\Users\Nilay\Desktop\Bindu
configfile: pytest.ini
plugins: anyio-4.10.0, langsmith-0.7.1, asyncio-0.26.0, cov-7.0.0, timeout-2.4.0, xdist-3.8.0, typeguard-4.4.2
asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=function, asyncio_default_test_loop_scope=function
collected 41 items
tests\unit\test_grpc_auth_interceptor.py ... [ 7%]
tests\unit\test_grpc_converters.py .............. [ 41%]
tests\unit\test_grpc_core_rpcs.py .............. [ 75%]
tests\unit\test_grpc_push_notifications.py .... [ 85%]
tests\unit\test_grpc_server.py ... [ 92%]
tests\integration\test_grpc_integration.py ... [100%]
====================================== PASSES =======================================
__________________ test_grpc_auth_interceptor_missing_token_aborts __________________
------------------------------- Captured stdout call --------------------------------
[17:21:49] WARNING Missing authorization metadata for gRPC call
/bindu.A2AService/ListTasks
__________________ test_grpc_auth_interceptor_invalid_token_aborts __________________
------------------------------- Captured stdout call --------------------------------
WARNING Invalid authorization token for gRPC call
/bindu.A2AService/ListTasks: invalid
___________________________ test_grpc_list_tasks_success ____________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
INFO TaskManager.list_tasks completed successfully
____________________________ test_grpc_list_tasks_error _____________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
INFO TaskManager.list_tasks completed successfully
___________________________ test_grpc_cancel_task_success ___________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
INFO TaskManager.cancel_task completed successfully
____________________________ test_grpc_cancel_task_error ____________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
INFO TaskManager.cancel_task completed successfully
__________________________ test_grpc_task_feedback_success __________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
INFO TaskManager.task_feedback completed successfully
___________________________ test_grpc_task_feedback_error ___________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
INFO TaskManager.task_feedback completed successfully
__________________________ test_grpc_list_contexts_success __________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
___________________________ test_grpc_list_contexts_error ___________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
__________________________ test_grpc_clear_context_success __________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
INFO Cleared context 55294913-21ae-4b26-a33f-e97b63574877:
removed 1 tasks
___________________________ test_grpc_clear_context_error ___________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
_________________________ test_grpc_stream_message_success __________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
__________________________ test_grpc_stream_message_error ___________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
____________________________ test_grpc_get_task_success _____________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
INFO TaskManager.get_task completed successfully
INFO GetTask completed:
task_id=603dcba3-d914-44d7-88fd-af6f05dc1430
___________________________ test_grpc_healthcheck_serving ___________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
INFO HealthCheck: status=SERVING
________________________ test_grpc_push_notification_success ________________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
_____________________ test_grpc_push_notification_not_supported _____________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
____________________ test_grpc_push_notification_task_not_found _____________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
____________________ test_grpc_push_notification_config_mismatch ____________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
_______________________ test_send_message_jsonrpc_grpc_parity _______________________
------------------------------- Captured stdout call --------------------------------
INFO TaskManager.send_message completed successfully
INFO A2AServicer initialized
INFO A2AServicer registered successfully
INFO gRPC server started on 127.0.0.1:41176
INFO Continuing existing task
00000000-0000-0000-0000-000000000003 from state
'input-required'
INFO TaskManager.send_message completed successfully
INFO SendMessage completed:
task_id=00000000-0000-0000-0000-000000000003
INFO Stopping gRPC server...
INFO gRPC server stopped
______________________ test_grpc_stream_message_emits_updates _______________________
------------------------------- Captured stdout call --------------------------------
INFO A2AServicer initialized
INFO A2AServicer registered successfully
INFO gRPC server started on 127.0.0.1:41180
INFO Stopping gRPC server...
INFO gRPC server stopped
_________________________ test_grpc_auth_metadata_enforced __________________________
------------------------------- Captured stdout call --------------------------------
INFO gRPC auth interceptor enabled
INFO A2AServicer initialized
INFO A2AServicer registered successfully
INFO gRPC server started on 127.0.0.1:41184
WARNING Missing authorization metadata for gRPC call
/bindu.a2a.v1.A2AService/SendMessage
INFO TaskManager.send_message completed successfully
INFO SendMessage completed:
task_id=00000000-0000-0000-0000-000000000009
INFO Stopping gRPC server...
INFO gRPC server stopped
============================== short test summary info ==============================
PASSED tests/unit/test_grpc_auth_interceptor.py::test_grpc_auth_interceptor_missing_token_aborts
PASSED tests/unit/test_grpc_auth_interceptor.py::test_grpc_auth_interceptor_invalid_token_aborts
PASSED tests/unit/test_grpc_auth_interceptor.py::test_grpc_auth_interceptor_valid_token_allows
PASSED tests/unit/test_grpc_converters.py::test_part_text_roundtrip
PASSED tests/unit/test_grpc_converters.py::test_part_file_roundtrip
PASSED tests/unit/test_grpc_converters.py::test_part_data_roundtrip
PASSED tests/unit/test_grpc_converters.py::test_proto_to_part_unknown_raises
PASSED tests/unit/test_grpc_converters.py::test_context_summary_to_proto_serializes_task_metadata
PASSED tests/unit/test_grpc_converters.py::test_push_notification_config_roundtrip
PASSED tests/unit/test_grpc_converters.py::test_task_push_notification_config_long_running_false_not_set
PASSED tests/unit/test_grpc_converters.py::test_task_event_status_update_includes_error_metadata
PASSED tests/unit/test_grpc_converters.py::test_task_event_artifact_update
PASSED tests/unit/test_grpc_converters.py::test_task_event_unknown_kind_raises
PASSED tests/unit/test_grpc_converters.py::test_message_roundtrip
PASSED tests/unit/test_grpc_converters.py::test_task_status_roundtrip
PASSED tests/unit/test_grpc_converters.py::test_artifact_roundtrip
PASSED tests/unit/test_grpc_converters.py::test_task_roundtrip
PASSED tests/unit/test_grpc_core_rpcs.py::test_grpc_list_tasks_success
PASSED tests/unit/test_grpc_core_rpcs.py::test_grpc_list_tasks_error
PASSED tests/unit/test_grpc_core_rpcs.py::test_grpc_cancel_task_success
PASSED tests/unit/test_grpc_core_rpcs.py::test_grpc_clear_context_success
PASSED tests/unit/test_grpc_core_rpcs.py::test_grpc_clear_context_error
PASSED tests/unit/test_grpc_core_rpcs.py::test_grpc_stream_message_success
PASSED tests/unit/test_grpc_core_rpcs.py::test_grpc_stream_message_error
PASSED tests/unit/test_grpc_core_rpcs.py::test_grpc_get_task_success
PASSED tests/unit/test_grpc_core_rpcs.py::test_grpc_healthcheck_serving
PASSED tests/unit/test_grpc_push_notifications.py::test_grpc_push_notification_success
PASSED tests/unit/test_grpc_push_notifications.py::test_grpc_push_notification_not_supported
PASSED tests/unit/test_grpc_push_notifications.py::test_grpc_push_notification_task_not_found
PASSED tests/unit/test_grpc_push_notifications.py::test_grpc_push_notification_config_mismatch
PASSED tests/unit/test_grpc_server.py::test_start_tls_missing_paths_raises
PASSED tests/unit/test_grpc_server.py::test_start_tls_missing_cert_file_raises
PASSED tests/unit/test_grpc_server.py::test_start_tls_missing_key_file_raises
PASSED tests/integration/test_grpc_integration.py::test_send_message_jsonrpc_grpc_parity
PASSED tests/integration/test_grpc_integration.py::test_grpc_stream_message_emits_updates
PASSED tests/integration/test_grpc_integration.py::test_grpc_auth_metadata_enforced
=========================== 41 passed, 1 warning in 0.48s ===========================
Human Verification (required)
What you personally verified (not just CI):
- Verified scenarios:
- gRPC server startup path
- gRPC auth interceptor behavior
- core gRPC RPC behavior (including added GetTask/HealthCheck coverage)
- converter edge cases
- docs/link presence
- fixed
tytype checking errors related toPushNotificationConfigandTaskPushNotificationConfig - added comprehensive tests for
config_loader,agent_token_utils, andschema_managerto successfully surpass the 70% test coverage threshold - fixed existing corrupted tests involving
AgentCredentialsinitialization andmock_engine.begin()AsyncMockevaluations - validated local dual-transport startup using
examples/beginner/echo_simple_agent.pywithBINDU_GRPC_ENABLED=true - validated local gRPC endpoint with a direct
HealthCheckclient call
- Edge cases checked:
- unknown/unsupported converter branches
- missing/invalid metadata token handling
- transport metadata behavior when gRPC is enabled
- What you did NOT verify:
- large-scale load/perf benchmarking
- external TLS deployment in production-like infra
- multi-node distributed rollout behavior
Compatibility / Migration
- Backward compatible? (
Yes/No): Yes - Config/env changes? (
Yes/No): Yes (gRPC enable/host/port/TLS-related config paths) - Database migration needed? (
Yes/No): No - If yes, exact upgrade steps:
- Pull latest branch.
- Set gRPC config/env values only if you want gRPC enabled.
- Keep gRPC disabled to retain existing behavior.
- Restart service and verify agent card/transport discovery as needed.
Failure Recovery (if this breaks)
- How to disable/revert this change quickly:
- Disable gRPC via config/env toggle and restart service.
- Revert PR commit(s) if needed.
- Files/config to restore:
- gRPC settings/auth/server wiring and related docs/tests from previous known-good commit.
- Known bad symptoms reviewers should watch for:
- gRPC server fails to bind/start
- token-auth failures on gRPC calls
- missing/incorrect transport metadata in agent card
- ad-hoc Python gRPC snippet fails with protobuf descriptor error unless
google.protobuf.struct_pb2is imported beforebindu.grpc.a2a_pb2
Risks and Mitigations
- Risk: gRPC auth regression due to validator integration path.
- Mitigation: dedicated auth interceptor tests + integration path checks.
- Risk: runtime startup conflicts when both transports are enabled.
- Mitigation: startup-path tests and explicit config-gated enablement.
- Risk: converter edge-case serialization mismatches.
- Mitigation: new focused converter test suite covering roundtrips and unknown-type handling.
- Risk: protobuf import-order issue in ad-hoc client snippets can cause descriptor-loading failure.
- Mitigation: preload
google.protobuf.struct_pb2in standalone snippets (tests already follow this pattern).
- Mitigation: preload
Checklist
- [x] Tests pass (
uv run pytest) - [x] Pre-commit hooks pass (
uv run pre-commit run --all-files) - [x] Documentation updated (if needed)
- [x] Security impact assessed
- [x] Human verification completed
- [x] Backward compatibility considered
hey @raahulrahl any update regarding this? already approved by @Paraschamoli sir