Orchestrata Ultimate › Tests › Reference › cxp

Tests reference — tests/cxp

tests/cxp — 47 test modules, 1005 test functions. Source tree: tests/cxp at commit 8a2cb42ad. Generated from the tests AST snapshot by scripts/gen-data-pages.py.

Prose pending.

Modules

Module Tests Covers
test_binary_serializer.py 27 3
test_constants.py 12 1
test_cxp_client.py 4 4
test_cxp_fields.py 16 5
test_cxp_kernel_endpoint.py 7 5
test_cxp_transport_e2e.py 16 4
test_delivery_status.py 19 3
test_deterministic_ids.py 6 1
test_direct_cxp_adapter.py 17 7
test_direct_cxp_adapter_teardown.py 3 4
test_direct_transport.py 13 1
test_direct_transport_fd_release.py 4 1
test_direct_transport_liveness.py 2 0
test_dispatcher.py 10 3
test_endpoint_config.py 20 1
test_enqueue_reply.py 3 3
test_exceptions.py 35 1
test_handler.py 4 2
test_headers.py 55 3
test_interfaces.py 21 1
test_json_serializer.py 36 3
test_native_queue_drain_regression.py 2 0
test_packet.py 9 1
test_packet_impl_extended.py 149 2
test_payload.py 53 3
test_payload_extended.py 82 3
test_postman_adapter.py 32 3
test_priority.py 7 3
test_prolog_bridge.py 62 4
test_prolog_bridge_extended.py 5 3
test_receive_packets_per_consumer.py 3 3
test_reply_router.py 14 4
test_router.py 21 4
test_schema.py 29 2
test_serializer.py 10 2
test_session_adapter.py 26 3
test_thread_store.py 8 4
test_threads.py 30 5
test_transport.py 5 2
test_types.py 11 1
test_validator.py 27 2
test_version.py 15 1
test_version_compat.py 8 1
test_websocket.py 26 2
test_work_status.py 18 3
test_ws_client.py 23 1

Module details

tests/cxp/test_binary_serializer.py

source · 27 tests · 227 lines

Tests for cxp.binary_serializer — BinarySerializer and helpers.

Covers: cxp.binary_serializer, cxp.exceptions, core.packet/ (package)

Kind Name Line Description
function test_encode_datetime_roundtrip 47
function test_encode_enum_returns_value 54
function test_encode_bytes_marker_roundtrip 59
function test_encode_set_sorted_list 65
function test_encode_frozenset_sorted_list 69
function test_encode_nested_dict 73
function test_encode_nested_list 78
function test_encode_passes_primitives 85
function test_decode_passes_plain_dict 91
function test_decode_unicode_bytes 95
function test_decode_non_utf8_bytes_kept 100
function test_has_msgpack_property 108
function test_to_bytes_returns_bytes 112
function test_to_bytes_prefix_is_msgpack 117
function test_roundtrip_preserves_core_fields 122
function test_roundtrip_preserves_priority 131
function test_roundtrip_with_bytes_payload 143
function test_from_bytes_rejects_non_bytes 158
function test_from_bytes_rejects_empty 163
function test_from_bytes_rejects_short 168
function test_from_bytes_rejects_unknown_prefix 173
function test_from_bytes_rejects_invalid_msgpack 178
function test_from_bytes_handles_gzip_json_prefix 183
function test_from_bytes_rejects_non_dict_msgpack 194
function test_from_bytes_rejects_packet_reconstruction_failure 201
function test_bytes_not_empty 211
function test_bytes_roundtrip_status 216

tests/cxp/test_constants.py

source · 12 tests · 82 lines

Tests for cxp.constants.

Covers: cxp.constants

Kind Name Line Description
class TestCXPConstants 28
method TestCXPConstants.test_protocol_identity 29
method TestCXPConstants.test_uuid_pattern_matches 33
method TestCXPConstants.test_uuid_pattern_rejects_invalid 37
method TestCXPConstants.test_semver_pattern_matches 41
method TestCXPConstants.test_semver_pattern_rejects_invalid 45
method TestCXPConstants.test_volk_alias_pattern_matches 49
method TestCXPConstants.test_volk_alias_pattern_rejects_invalid 53
method TestCXPConstants.test_field_limits 58
method TestCXPConstants.test_priority_range 64
method TestCXPConstants.test_ttl_limits 68
method TestCXPConstants.test_delivery_defaults 73
method TestCXPConstants.test_performance_targets 77

tests/cxp/test_cxp_client.py

source · 4 tests · 183 lines

Test Standards Compliance (see AGENTS.md § Test Standards):

Covers: cxp.proto_codec, cxp.servicer, cxp.transport, core.packet/ (package)

Kind Name Line Description
function test_send_packet_zero_max_retries_returns_default_failure 63 max_retries=0 means the retry loop (range(0)) never executes at all, so
function test_receive_packets_auto_connects_when_not_connected 91
function test_packet_to_proto_wraps_non_dict_payload_as_string 148 When packet.payload is truthy but not a dict, packet_to_proto must wrap
function test_packet_to_proto_copies_existing_protobuf_timestamp 166 When packet.timestamp is already a protobuf Timestamp (not a datetime),

tests/cxp/test_cxp_fields.py

source · 16 tests · 422 lines

Test Standards Compliance (see AGENTS.md § Test Standards):

Covers: cxp.proto.cxp_pb2, cxp.proto_codec, cxp.servicer, cxp.transport, core.packet/ (package)

Kind Name Line Description
function test_send_packet_preserves_packet_type_and_metadata 74 A non-default packet_type and metadata must survive client→server.
function test_send_packet_preserves_error_packet_type 132 PacketType.ERROR (used by self-healing) must round-trip, not be lost.
function test_packet_to_proto_maps_all_packet_types 174 Every model PacketType maps to the matching proto enum (no value/name mix-up).
function test_dict_to_proto_preserves_non_default_enums 203 _dict_to_proto must echo non-default enum values, not hardcode them.
function test_dict_to_proto_falls_back_to_defaults_when_absent 233 Missing/empty enum keys fall back to QUEUED / PENDING / MESSAGE.
function test_receive_packet_preserves_non_default_enums_over_grpc 250 A queued packet with non-default enums streams back intact via receive_packet.
function test_enum_token_unwraps_generic_enum_value 306 _enum_token pulls .value off a plain (non-str/int) Enum member.
function test_enum_token_passthrough_for_str_and_none 311
function test_delivery_str_to_proto_unknown_token_falls_back_to_queued 316 An unrecognized delivery-status token falls back to QUEUED rather than
function test_work_str_to_proto_unknown_token_falls_back_to_pending 325
function test_packet_type_str_to_proto_unknown_token_falls_back_to_message 331
function test_packet_type_str_to_proto_resolves_by_enum_name_not_value 338 PacketType.ACKNOWLEDGEMENT has value "ack" but proto enum name
function test_dict_to_proto_populates_non_empty_payload 355
function test_dict_to_proto_populates_metadata 370
function test_dict_to_proto_accepts_datetime_timestamp 385 A real datetime object (the type Timestamp.FromDatetime natively wants)
function test_dict_to_proto_parses_iso_string_timestamp 403 Regression: _proto_to_dict encodes timestamp as an ISO-8601 string

tests/cxp/test_cxp_kernel_endpoint.py

source · 7 tests · 206 lines

Covers: agents.runtime_main, cxp.endpoint_config, cxp.proto_codec, cxp.servicer, cxp.transport

Kind Name Line Description
function test_kernel_ports_resolve_from_single_env_source 59 Every component that needs the CXP kernel port resolves it from the SAME
function test_missing_port_raises_rather_than_defaulting 76 A missing port var raises — proving there is NO hardcoded fallback.
function test_port_from_endpoint_parses_explicit_port 85
function test_port_from_endpoint_rejects_missing_port 89
function test_port_from_endpoint_rejects_non_integer 94
function test_server_registers_both_services 125 A CXPServer RPC and a CXPReceiver RPC both succeed against one server —
function test_get_status_returns_live_roster 150 GetStatus (synchronous status RPC) returns the roster the kernel handler

tests/cxp/test_cxp_transport_e2e.py

source · 16 tests · 512 lines

Test Standards Compliance (see AGENTS.md § Test Standards):

Covers: cxp.proto.cxp_pb2, cxp.proto_codec, cxp.servicer, cxp.transport

Kind Name Line Description
function test_cxp_servicer_send_packet_direct 97
function test_cxp_servicer_send_packet_with_handler 116
function test_cxp_servicer_send_packet_stream_direct 135
function test_cxp_servicer_receive_packet_direct 157
function test_cxp_servicer_subscribe_direct 187
function test_cxp_servicer_subscribe_filter_no_match 218
function test_cxp_servicer_acknowledge_direct 248
function test_cxp_servicer_stats_property 260 The stats property exposes the live CXPStats instance (not a copy).
function test_cxp_servicer_send_packet_with_async_handler 269 send_packet awaits a coroutine-returning handler (not just sync callables).
function test_cxp_servicer_send_packet_handler_raises 293 A handler that raises yields a failed CXPReceipt, not a crashed RPC.
function test_cxp_servicer_send_packet_queues_reply_packet 316 A handler-produced reply_packet is enqueued for streaming consumers.
function test_cxp_servicer_get_status_with_async_handler 360 get_status awaits a coroutine-returning handler for the status subject.
function test_cxp_servicer_subscribe_filter_from_agents_no_match 390 Subject matches but from_agents doesn't — subscription must still filter.
function test_cxp_server_serve_forever 426
function test_grpc_client_receive_packets 443 The CXP client's receive_packets collects packets from the servicer.
function test_grpc_client_subscribe_direct 492 The CXP client's subscribe starts streaming; server keeps stream open.

tests/cxp/test_delivery_status.py

source · 19 tests · 171 lines

Tests for CXP delivery status tracking.

Covers: cxp.delivery_status, cxp.exceptions, core.packet/ (package)

Kind Name Line Description
class TestValidateDeliveryTransition 36 Tests for validate_delivery_transition.
method TestValidateDeliveryTransition.test_queued_to_delivered 39
method TestValidateDeliveryTransition.test_queued_to_failed 47
method TestValidateDeliveryTransition.test_queued_to_acknowledged 53
method TestValidateDeliveryTransition.test_delivered_to_acknowledged 61
method TestValidateDeliveryTransition.test_delivered_to_failed 69
method TestValidateDeliveryTransition.test_acknowledged_to_any 77
method TestValidateDeliveryTransition.test_failed_to_any 85
class TestDeliveryTracker 94 Tests for DeliveryTracker.
method TestDeliveryTracker.test_init_defaults 97
method TestDeliveryTracker.test_init_custom 102
method TestDeliveryTracker.test_set_status_valid 107
method TestDeliveryTracker.test_set_status_invalid_raises 113
method TestDeliveryTracker.test_get_history 120
method TestDeliveryTracker.test_get_history_empty 130
method TestDeliveryTracker.test_record_failure 135
method TestDeliveryTracker.test_get_failure_reasons_empty 142
method TestDeliveryTracker.test_increment_retry 147
method TestDeliveryTracker.test_increment_retry_exceeded 154
method TestDeliveryTracker.test_can_retry_true 162
method TestDeliveryTracker.test_can_retry_false 167

tests/cxp/test_deterministic_ids.py

source · 6 tests · 66 lines

Tests for cxp.deterministic_ids.

Covers: cxp.deterministic_ids

Kind Name Line Description
class TestDeterministicIds 33
method TestDeterministicIds.test_namespace_is_uuid 34
method TestDeterministicIds.test_same_input_same_id 37
method TestDeterministicIds.test_different_input_different_id 43
method TestDeterministicIds.test_returns_valid_uuid 49
method TestDeterministicIds.test_isoformat_used 55
method TestDeterministicIds.test_string_timestamp 61

tests/cxp/test_direct_cxp_adapter.py

source · 17 tests · 503 lines

Real-transport tests for the cxpt-backed CXP direct adapter.

Covers: cxp.direct_cxp_adapter, cxp.direct_transport, cxp.proto.cxp_pb2, cxp.proto_codec, cxp.servicer, cxp.transport, core.packet/ (package)

Kind Name Line Description
function test_send_packet_roundtrip_preserves_fields 86
function test_send_packets_loops_send_packet 119
function test_health_check_and_get_status 137
function test_acknowledge_returns_bool 186
function test_receive_packets_streams_multiple_and_terminates 203
function test_subscribe_streams_matching_packets_then_blocks 231
function test_subscribe_filters_non_matching_subjects 269
function test_unknown_method_returns_unimplemented 299
function test_dispatch_before_start_returns_unimplemented 311
function test_serve_forever_before_start_raises 320
function test_receive_packets_respects_max_messages 326
function test_require_client_raises_when_never_connected 349
function test_resolve_target_defaults_to_tcp_from_config 360
function test_resolve_target_prefers_uds_path_from_env 378
function test_gil_stays_off 387
function test_subscribe_cancel_stops_queue_wait_and_releases_stream 400 Backlog #23 through the FULL adapter stack, not just the transport.
function test_send_packet_retries_transport_failures_with_backoff 448 max_retries must actually drive attempts, not sit unread.

tests/cxp/test_direct_cxp_adapter_teardown.py

source · 3 tests · 198 lines

Regression test for the free-threaded teardown deadlock in DirectCXPServer.

Covers: cxp.direct_cxp_adapter, cxp.direct_transport, cxp.servicer, core.packet/ (package)

Kind Name Line Description
function test_dispatch_on_closed_loop_returns_unavailable 47 Whitebox: the defense-in-depth guard added alongside the stop() fix.
function test_drive_stream_on_closed_loop_ends_cleanly 65 Whitebox: _drive_stream must not hang or raise once the loop it needs
function test_stop_does_not_deadlock_and_leaves_no_zombie_handler_threads 172

tests/cxp/test_direct_transport.py

source · 13 tests · 377 lines

Real-transport tests for the cxpt-backed CXP direct transport.

Covers: cxp.direct_transport

Kind Name Line Description
function test_unary_roundtrip 79
function test_error_status_raises 87
function test_handler_exception_becomes_internal 96
function test_concurrent_calls_are_correlated 105
function test_gil_stays_off 118
function test_stream_yields_all_items_in_order 125
function test_stream_empty_terminates_cleanly 132
function test_stream_handler_exception_raises_after_partial 139
function test_concurrent_streams_are_correlated 155
function test_unary_and_stream_interleaved 171
function test_stream_cancel_stops_production_and_releases_resources 212
function test_stream_cancel_no_hang_across_many_iterations 304
function test_unary_call_times_out_when_the_peer_never_replies 336 A request whose peer never answers must raise, not hang forever.

tests/cxp/test_direct_transport_fd_release.py

source · 4 tests · 261 lines

File-descriptor release regression for the cxpt native server.

Covers: cxp.direct_transport

Kind Name Line Description
function test_disconnected_client_fd_is_released 116 Serial connect/disconnect must not grow the server's fd table.
function test_many_sequential_clients_do_not_exhaust_the_fd_table 154 The wedge itself: enough churn to blow a small fd budget.
function test_the_measurement_ignores_descriptors_this_test_never_opened 185 Unrelated fd churn in the same process must not read as a leak.
function test_server_still_serves_after_heavy_connection_churn 229 Releasing fds must not break the live path.

tests/cxp/test_direct_transport_liveness.py

source · 2 tests · 136 lines

Acceptor-liveness regression for the cxpt native server.

Kind Name Line Description
function test_acceptor_survives_fd_exhaustion 112 EMFILE during accept() must not kill the native acceptor thread.
function test_connection_refused_reports_cleanly 127 Sanity companion: a target nobody listens on fails fast at the socket

tests/cxp/test_dispatcher.py

source · 10 tests · 128 lines

Tests for cxp.dispatcher.

Covers: cxp.dispatcher, cxp.types, core.packet/ (package)

Kind Name Line Description
class TestCXPDispatcher 30
method TestCXPDispatcher.test_dispatch_delivers 44
method TestCXPDispatcher.test_dispatch_to 50
method TestCXPDispatcher.test_broadcast 55
method TestCXPDispatcher.test_history 60
method TestCXPDispatcher.test_history_after_dispatch 64
method TestCXPDispatcher.test_max_retries_default 69
method TestCXPDispatcher.test_dispatch_with_rejecting_router 72
method TestCXPDispatcher.test_dispatch_with_router_target 87
method TestCXPDispatcher.test_deliver_exception_becomes_failure 104
method TestCXPDispatcher.test_record_failure_with_tracker 117

tests/cxp/test_endpoint_config.py

source · 20 tests · 163 lines

Tests for cxp.endpoint_config — CXP gRPC endpoint config resolution.

Covers: cxp.endpoint_config

Kind Name Line Description
function test_require_port_returns_int_for_valid_value 25
function test_require_port_raises_when_unset 30
function test_require_port_raises_when_empty 36
function test_require_port_raises_on_non_integer 42
function test_require_port_raises_below_range 48
function test_require_port_raises_above_range 54
function test_port_from_endpoint_parses_grpc_scheme 65
function test_port_from_endpoint_parses_cxp_scheme 69
function test_port_from_endpoint_parses_bare_host_port 73
function test_port_from_endpoint_rejects_missing_port 77
function test_port_from_endpoint_rejects_non_integer_port 82
function test_cxp_grpc_port_prefers_explicit_port_var 92
function test_cxp_grpc_port_falls_back_to_endpoint 100
function test_cxp_grpc_port_raises_when_neither_var_set 105
function test_cxp_grpc_port_treats_changeme_endpoint_as_unset 113 An unsubstituted .env template sentinel (CHANGEME_*) means 'not
function test_cxp_grpc_host_reads_env_value 128
function test_cxp_grpc_host_defaults_to_localhost 133
function test_cxp_grpc_endpoint_returns_explicit_value 143
function test_cxp_grpc_endpoint_derives_from_host_and_port 148
function test_cxp_grpc_endpoint_treats_changeme_sentinel_as_unset 156 A sentinel CXP_GRPC_ENDPOINT falls back to the derived host:port.

tests/cxp/test_enqueue_reply.py

source · 3 tests · 136 lines

Test Standards Compliance (see AGENTS.md § Test Standards):

Covers: cxp.proto.cxp_pb2, cxp.servicer, cxp.transport

Kind Name Line Description
function test_enqueue_reply_lands_on_queue_a_live_receive_packet_drains 74 enqueue_reply puts the dict on the queue; a live receive_packet drain sees it.
function test_send_packet_reply_branch_routes_through_enqueue_reply 94 send_packet's inline reply_packet branch delegates to enqueue_reply.
function test_cxp_server_servicer_property_returns_registered_servicer 132 CXPServer.servicer is the exact CXPServicer instance the server registered.

tests/cxp/test_exceptions.py

source · 35 tests · 282 lines

Tests for cxp.exceptions — CXP exception hierarchy and error codes.

Covers: cxp.exceptions

Kind Name Line Description
function test_cxp_error_is_exception 28
function test_cxp_error_custom_code_and_details 37
function test_cxp_error_to_dict_without_details 43
function test_cxp_error_to_dict_with_details 49
function test_cxp_error_none_details_becomes_empty_dict 55
function test_invalid_packet_error_defaults 63
function test_invalid_packet_error_with_field 71
function test_invalid_packet_error_is_cxp_error 77
function test_serialization_error_defaults 84
function test_serialization_error_custom_format 90
function test_deserialization_error_defaults 95
function test_deserialization_error_custom_format 101
function test_serialization_errors_inherit_cxp 106
function test_validation_error_defaults 114
function test_validation_error_with_errors_and_warnings 123
function test_field_validation_error 129
function test_schema_validation_error 141
function test_delivery_error_defaults 150
function test_delivery_error_with_ids 156
function test_delivery_timeout_error 162
function test_delivery_timeout_error_without_timeout 170
function test_max_retries_exceeded_error 176
function test_routing_error_defaults 187
function test_routing_error_with_packet 192
function test_no_route_error 197
function test_no_route_error_custom_message 206
function test_thread_error_defaults 214
function test_thread_error_with_id 219
function test_thread_not_found_error 224
function test_thread_closed_error 232
function test_state_transition_error 242
function test_state_transition_error_custom_type 252
function test_prolog_bridge_error_defaults 263
function test_prolog_bridge_error_with_operation 268
function test_can_catch_all_via_cxp_error 276

tests/cxp/test_handler.py

source · 4 tests · 77 lines

Tests for cxp/handler.py — real implementation.

Covers: cxp.handler, core.packet/ (package)

Kind Name Line Description
class TestCXPHandler 35
method TestCXPHandler.test_init 36
method TestCXPHandler.test_init_with_config 41
method TestCXPHandler.test_handle_packet_with_recipient 46
method TestCXPHandler.test_route_packet 64

tests/cxp/test_headers.py

source · 55 tests · 356 lines

Tests for cxp.headers — header extraction, validation, and mutation.

Covers: cxp.exceptions, cxp.headers, core.packet/ (package)

Kind Name Line Description
function test_validate_uuid_accepts_valid_uuid 47
function test_validate_uuid_rejects_invalid_string 51
function test_validate_uuid_rejects_non_string 55
function test_validate_uuid_accepts_mixed_case 60
function test_validate_volk_alias_accepts_valid 64
function test_validate_volk_alias_rejects_invalid 69
function test_validate_volk_alias_rejects_non_string 76
function test_validate_subject_accepts_valid 81
function test_validate_subject_rejects_empty 86
function test_validate_subject_rejects_too_long 90
function test_validate_subject_accepts_max_length 94
function test_validate_subject_rejects_non_string 98
function test_core_header_fields_count 106
function test_field_sets_are_disjoint 110
function test_field_sets_cover_all_governed_core 116
function test_extract_headers_returns_all_core_fields 126
function test_extract_headers_normalizes_enum_values 132
function test_get_headers_via_manager 138
function test_get_immutable_headers 146
function test_get_mutable_headers 153
function test_validate_header_unknown_field_raises 163
function test_validate_header_message_id_valid 168
function test_validate_header_message_id_invalid 172
function test_validate_header_from_agent_valid_alias 176
function test_validate_header_from_agent_empty_invalid 180
function test_validate_header_thread_id 185
function test_validate_header_subject 190
function test_validate_header_payload_any_value 195
function test_validate_header_timestamp_must_be_datetime 201
function test_validate_header_priority_int_in_range 206
function test_validate_header_priority_enum 214
function test_validate_header_priority_non_int_invalid 218
function test_validate_header_delivery_status_enum_valid 222
function test_validate_header_delivery_status_string_valid 228
function test_validate_header_delivery_status_string_invalid 232
function test_validate_header_work_status_enum 237
function test_validate_header_work_status_string 241
function test_validate_header_protocol_version_valid_semver 247
function test_validate_header_protocol_version_invalid 251
function test_validate_all_headers_passes 260
function test_validate_all_headers_collects_errors 265
function test_set_priority_valid 278
function test_set_priority_too_high 283
function test_set_priority_too_low 288
function test_set_priority_non_int 293
function test_set_delivery_status_valid 301
function test_set_delivery_status_accepts_string 306
function test_set_delivery_status_invalid_string_raises 311
function test_set_delivery_status_invalid_transition 316
function test_set_delivery_status_terminal_failed 323
function test_set_work_status_valid 332
function test_set_work_status_accepts_string 337
function test_set_work_status_invalid_string_raises 342
function test_set_work_status_full_lifecycle 347
function test_set_work_status_invalid_transition_raises 354

tests/cxp/test_interfaces.py

source · 21 tests · 306 lines

Structural tests for cxp.interfaces — Protocol classes.

Covers: cxp.interfaces

Kind Name Line Description
function test_all_exports_exist 35
function test_expected_protocols_exported 40
function test_all_are_protocols 55
function test_all_are_runtime_checkable 60
function test_ipacket_declares_required_properties 87
function test_ipacket_declares_required_methods 92
function test_ipacket_isinstance_missing_fields 98
function test_ipacket_isinstance_matches_when_all_attrs_present 105
function test_iserializer_methods 134
function test_iserializer_isinstance_missing 140
function test_iserializer_isinstance_matches 147
function test_ivalidator_methods 170
function test_ivalidator_isinstance 176
function test_ithreadmanager_methods 202
function test_ithreadmanager_isinstance 208
function test_ideliverytracker_methods 234
function test_ideliverytracker_isinstance 240
function test_iprolog_methods 268
function test_iprolog_isinstance 274
function test_all_protocols_have_docstrings 294
function test_ipacket_has_type_hints 302

tests/cxp/test_json_serializer.py

source · 36 tests · 288 lines

Tests for cxp.json_serializer — CXPEncoder and JSONSerializer.

Covers: cxp.exceptions, cxp.json_serializer, core.packet/ (package)

Kind Name Line Description
function test_encoder_datetime_becomes_isoformat 46
function test_encoder_enum_returns_value 53
function test_encoder_bytes_becomes_base64_marker 59
function test_encoder_set_sorted_list 66
function test_encoder_frozenset_sorted_list 71
function test_encoder_nan_becomes_null 76
function test_encoder_infinity_becomes_null 82
function test_encoder_sanitize_nested_nan 88
function test_encoder_default_raises_for_unsupported 95
function test_decode_bytes_hook_restores_bytes 104
function test_decode_bytes_hook_passes_through_dict 109
function test_decode_bytes_hook_ignores_multi_key 113
function test_to_json_basic_roundtrip 121
function test_to_json_returns_str 129
function test_to_json_pretty_has_indent 133
function test_to_json_contains_valid_json 140
function test_to_json_with_bytes_payload 147
function test_to_json_with_nan_payload 159
function test_from_json_roundtrip_preserves_priority 174
function test_from_json_rejects_non_string 186
function test_from_json_rejects_invalid_json 191
function test_from_json_rejects_non_object_root 196
function test_from_json_rejects_missing_required 201
function test_to_dict_returns_dict 210
function test_from_dict_rebuilds_packet 216
function test_from_dict_rejects_non_dict 222
function test_from_dict_rejects_invalid_payload 227
function test_needs_custom_encoding_detects_datetime 235
function test_needs_custom_encoding_detects_bytes 240
function test_needs_custom_encoding_detects_set 245
function test_needs_custom_encoding_detects_nan 249
function test_needs_custom_encoding_detects_enum 253
function test_needs_custom_encoding_plain_data 257
function test_needs_custom_encoding_nested_detection 261
function test_to_json_raises_serialization_error_on_bad_packet 269
function test_to_dict_raises_serialization_error_on_bad_packet 280

tests/cxp/test_native_queue_drain_regression.py

source · 2 tests · 108 lines

Regression test: deallocating a cxpt.Server with a NON-EMPTY queue.

Kind Name Line Description
function test_server_dealloc_survives_pending_requests 67 Tearing down a server with queued requests must not raise a fatal signal.
function test_queued_payloads_are_not_freed_through_the_advanced_cursor 84 The specific corruption, made observable rather than inferred.

tests/cxp/test_packet.py

source · 9 tests · 63 lines

Tests for the CXPPacket vocabulary (home: orchestrata_ultimate.core.packet).

Covers: core.packet/ (package)

Kind Name Line Description
class TestPacketReexports 35
method TestPacketReexports.test_cxp_packet_importable 36
method TestPacketReexports.test_delivery_result_importable 39
method TestPacketReexports.test_delivery_status_importable 42
method TestPacketReexports.test_packet_type_importable 45
method TestPacketReexports.test_priority_importable 48
method TestPacketReexports.test_queue_status_importable 51
method TestPacketReexports.test_validation_result_importable 54
method TestPacketReexports.test_work_status_importable 57
method TestPacketReexports.test_can_construct_packet 60

tests/cxp/test_packet_impl_extended.py

source · 149 tests · 1426 lines

Extended tests for the CXPPacket implementation (core.packet.packet) to increase coverage.

Covers: core.packet.packet, cxp.exceptions

Kind Name Line Description
class TestPacketHeader 82 Tests for deprecated PacketHeader dataclass.
method TestPacketHeader.test_to_dict_with_expires_at 85
method TestPacketHeader.test_to_dict_no_expires_at 112
method TestPacketHeader.test_from_dict_type_as_string 126
method TestPacketHeader.test_from_dict_priority_as_string 140
method TestPacketHeader.test_from_dict_priority_as_int 153
method TestPacketHeader.test_from_dict_priority_invalid_fallback 166
method TestPacketHeader.test_from_dict_created_at_string 179
method TestPacketHeader.test_from_dict_expires_at_string 192
class TestPacketPayload 213 Tests for deprecated PacketPayload dataclass.
method TestPacketPayload.test_to_dict_serializes_body 216
method TestPacketPayload.test_to_dict_primitive_body_unchanged 221
method TestPacketPayload.test_from_dict_parses_json_body 226
method TestPacketPayload.test_from_dict_invalid_json_body_keeps_string 232
class TestHeaderProxy 244 Tests for HeaderProxy legacy accessor.
method TestHeaderProxy.test_sender_getter 247
method TestHeaderProxy.test_sender_setter 251
method TestHeaderProxy.test_recipient_getter 256
method TestHeaderProxy.test_recipient_setter 260
method TestHeaderProxy.test_packet_id_getter 265
method TestHeaderProxy.test_packet_id_setter 269
method TestHeaderProxy.test_type_getter 274
method TestHeaderProxy.test_type_setter 278
method TestHeaderProxy.test_priority_getter_from_int 283
method TestHeaderProxy.test_priority_getter_invalid_fallback 288
method TestHeaderProxy.test_priority_setter_with_priority 293
method TestHeaderProxy.test_priority_setter_with_int 298
method TestHeaderProxy.test_created_at_getter 303
method TestHeaderProxy.test_created_at_setter 307
method TestHeaderProxy.test_expires_at_getter 313
method TestHeaderProxy.test_expires_at_setter 321
method TestHeaderProxy.test_correlation_id_getter 327
method TestHeaderProxy.test_correlation_id_setter 332
method TestHeaderProxy.test_conversation_id_getter 337
method TestHeaderProxy.test_conversation_id_setter_with_none 342
method TestHeaderProxy.test_conversation_id_setter_with_value 347
method TestHeaderProxy.test_ttl_getter 352
method TestHeaderProxy.test_ttl_setter 356
method TestHeaderProxy.test_version_getter 361
method TestHeaderProxy.test_reply_to_getter 365
method TestHeaderProxy.test_reply_to_setter 370
method TestHeaderProxy.test_tags_getter 375
method TestHeaderProxy.test_signature_from_metadata 380
method TestHeaderProxy.test_signature_none_when_missing 385
method TestHeaderProxy.test_encryption_key_id_from_metadata 389
method TestHeaderProxy.test_encryption_key_id_none_when_missing 394
method TestHeaderProxy.test_to_dict_with_all_optionals 398
method TestHeaderProxy.test_to_dict_without_optionals 408
class TestHeadersDict 421 Tests for HeadersDict compatibility wrapper.
method TestHeadersDict.test_get_known_keys 424
method TestHeadersDict.test_get_unknown_returns_default 436
method TestHeadersDict.test_getitem_known 441
method TestHeadersDict.test_getitem_unknown_raises 445
method TestHeadersDict.test_contains_known 450
method TestHeadersDict.test_contains_unknown 456
class TestCXPPacketInit 467 Tests for CXPPacket construction edge cases.
method TestCXPPacketInit.test_init_from_header_with_signature_and_key 470
method TestCXPPacketInit.test_validate_missing_from_agent 477
method TestCXPPacketInit.test_validate_missing_to_agent 481
method TestCXPPacketInit.test_validate_non_positive_ttl 485
method TestCXPPacketInit.test_headers_property 489
class TestCXPPacketLifecycle 500 Tests for delivery and work status lifecycle methods.
method TestCXPPacketLifecycle.test_is_expired_true 503
method TestCXPPacketLifecycle.test_is_expired_false 512
method TestCXPPacketLifecycle.test_is_expired_no_expires_at 521
method TestCXPPacketLifecycle.test_can_retry_when_expired 530
method TestCXPPacketLifecycle.test_can_retry_when_max_attempts_reached 539
method TestCXPPacketLifecycle.test_can_retry_when_next_retry_in_future 548
method TestCXPPacketLifecycle.test_can_retry_allowed 557
method TestCXPPacketLifecycle.test_check_delivery_transition_valid 566
method TestCXPPacketLifecycle.test_check_delivery_transition_invalid 571
method TestCXPPacketLifecycle.test_check_work_transition_valid 576
method TestCXPPacketLifecycle.test_check_work_transition_invalid 583
method TestCXPPacketLifecycle.test_mark_for_retry_from_queued 588
method TestCXPPacketLifecycle.test_mark_for_retry_from_delivered 596
method TestCXPPacketLifecycle.test_mark_for_retry_from_acknowledged_raises 603
method TestCXPPacketLifecycle.test_mark_delivered 610
method TestCXPPacketLifecycle.test_mark_failed 616
method TestCXPPacketLifecycle.test_mark_acknowledged 621
method TestCXPPacketLifecycle.test_start_work 627
method TestCXPPacketLifecycle.test_resolve_work 632
method TestCXPPacketLifecycle.test_archive_work 638
method TestCXPPacketLifecycle.test_requeue_work 645
class TestCXPPacketIPacketMethods 657 Tests for get_headers, validate, create_ack, create_error.
method TestCXPPacketIPacketMethods.test_get_headers_returns_all_fields 660
method TestCXPPacketIPacketMethods.test_get_headers_normalizes_enum_values 676
method TestCXPPacketIPacketMethods.test_validate_valid_packet 688
method TestCXPPacketIPacketMethods.test_validate_missing_from_agent 694
method TestCXPPacketIPacketMethods.test_validate_missing_to_agent 701
method TestCXPPacketIPacketMethods.test_validate_missing_message_id 708
method TestCXPPacketIPacketMethods.test_validate_missing_thread_id 715
method TestCXPPacketIPacketMethods.test_validate_non_positive_ttl 722
method TestCXPPacketIPacketMethods.test_validate_priority_out_of_range_high 729
method TestCXPPacketIPacketMethods.test_validate_priority_out_of_range_low 736
method TestCXPPacketIPacketMethods.test_validate_subject_too_long 743
method TestCXPPacketIPacketMethods.test_validate_same_sender_recipient_warning 749
method TestCXPPacketIPacketMethods.test_validate_expired_warning 755
method TestCXPPacketIPacketMethods.test_create_ack 765
method TestCXPPacketIPacketMethods.test_create_error 782
class TestCXPPacketSerialization 806 Tests for to_dict and from_dict edge cases.
method TestCXPPacketSerialization.test_to_dict_with_packet_payload 809
method TestCXPPacketSerialization.test_to_dict_with_correlation_id 821
method TestCXPPacketSerialization.test_to_dict_with_reply_to 831
method TestCXPPacketSerialization.test_to_dict_with_tags 841
method TestCXPPacketSerialization.test_to_dict_with_metadata 851
method TestCXPPacketSerialization.test_to_dict_with_expires_at 861
method TestCXPPacketSerialization.test_to_dict_with_last_delivery_attempt 871
method TestCXPPacketSerialization.test_to_dict_with_next_retry_at 881
method TestCXPPacketSerialization.test_to_dict_header_empty_when_no_from_agent 891
method TestCXPPacketSerialization.test_to_dict_timestamp_non_datetime 900
method TestCXPPacketSerialization.test_from_dict_legacy_format 910
method TestCXPPacketSerialization.test_from_dict_legacy_with_raw_payload 928
method TestCXPPacketSerialization.test_from_dict_legacy_delivery_status_pending_maps_to_queued 937
method TestCXPPacketSerialization.test_from_dict_legacy_delivery_status_retrying_maps_to_queued 946
method TestCXPPacketSerialization.test_from_dict_legacy_delivery_status_expired_maps_to_failed 955
method TestCXPPacketSerialization.test_from_dict_flat_pending_maps_to_queued 964
method TestCXPPacketSerialization.test_from_dict_flat_with_last_delivery_attempt 974
method TestCXPPacketSerialization.test_from_dict_flat_with_next_retry_at 986
method TestCXPPacketSerialization.test_from_dict_flat_with_string_timestamp 996
method TestCXPPacketSerialization.test_from_dict_flat_with_string_expires_at 1006
method TestCXPPacketSerialization.test_from_dict_flat_with_enum_strings 1016
class TestCXPPacketEqualityRepr 1036 Tests for eq and repr.
method TestCXPPacketEqualityRepr.test_eq_same_message_id 1039
method TestCXPPacketEqualityRepr.test_eq_different_message_id 1048
method TestCXPPacketEqualityRepr.test_eq_non_packet_returns_not_implemented 1057
method TestCXPPacketEqualityRepr.test_repr_contains_fields 1061
class TestDeliveryResult 1076 Tests for DeliveryResult dataclass.
method TestDeliveryResult.test_to_dict 1079
method TestDeliveryResult.test_from_dict 1096
class TestQueueStatus 1116 Tests for QueueStatus dataclass.
method TestQueueStatus.test_to_dict_with_dates 1119
method TestQueueStatus.test_to_dict_without_dates 1135
method TestQueueStatus.test_from_dict 1147
class TestValidationResult 1168 Tests for ValidationResult dataclass.
method TestValidationResult.test_to_dict 1171
method TestValidationResult.test_from_dict 1186
class TestTypeValidationErrors 1206 Tests for type validation and error paths.
method TestTypeValidationErrors.test_header_proxy_priority_setter_non_priority_int 1209
method TestTypeValidationErrors.test_cxp_packet_init_with_priority_enum 1214
method TestTypeValidationErrors.test_cxp_packet_init_with_priority_int 1223
method TestTypeValidationErrors.test_packet_header_from_dict_no_type_no_priority 1232
method TestTypeValidationErrors.test_from_dict_flat_with_non_string_packet_type 1244
method TestTypeValidationErrors.test_from_dict_flat_with_non_string_delivery_status 1254
method TestTypeValidationErrors.test_from_dict_flat_with_non_string_work_status 1264
method TestTypeValidationErrors.test_header_proxy_to_dict_with_non_datetime_created_at 1274
method TestTypeValidationErrors.test_header_proxy_to_dict_with_non_datetime_expires_at 1280
method TestTypeValidationErrors.test_to_dict_with_non_datetime_expires_at 1286
class TestProtocolVersionHandling 1303 Tests for protocol_version field behavior.
method TestProtocolVersionHandling.test_default_protocol_version 1306
method TestProtocolVersionHandling.test_custom_protocol_version 1310
method TestProtocolVersionHandling.test_protocol_version_in_to_dict 1319
method TestProtocolVersionHandling.test_protocol_version_roundtrip_via_from_dict 1329
method TestProtocolVersionHandling.test_header_proxy_version_matches_packet 1340
method TestProtocolVersionHandling.test_legacy_header_version_passed_to_packet 1349
class TestBufferHandling 1365 Tests for body and payload buffer handling.
method TestBufferHandling.test_packet_payload_to_dict_with_list_body 1368
method TestBufferHandling.test_packet_payload_to_dict_with_none_body 1373
method TestBufferHandling.test_packet_payload_to_dict_with_int_body 1378
method TestBufferHandling.test_packet_payload_to_dict_with_bool_body 1383
method TestBufferHandling.test_packet_payload_to_dict_with_float_body 1388
method TestBufferHandling.test_packet_payload_to_dict_with_nested_dict_body 1393
method TestBufferHandling.test_cxp_packet_to_dict_payload_is_dict 1398
method TestBufferHandling.test_cxp_packet_to_dict_payload_is_bytes 1408
method TestBufferHandling.test_cxp_packet_to_dict_payload_is_none 1418

tests/cxp/test_payload.py

source · 53 tests · 351 lines

Tests for cxp.payload — PayloadManager get/set, content type, sizes.

Covers: cxp.exceptions, cxp.payload, core.packet/ (package)

Kind Name Line Description
function test_size_limits_values 32
function test_get_payload_none_returns_none 40
function test_get_payload_dict_returns_dict 45
function test_get_payload_raw_bytes_returns_bytes 50
function test_get_payload_bytearray_returns_bytes 55
function test_get_payload_decodes_binary_envelope 62
function test_get_payload_decompresses_compressed_envelope 67
function test_get_payload_json_none 76
function test_get_payload_json_dict 81
function test_get_payload_json_raises_for_raw_bytes 86
function test_get_payload_json_handles_non_serializable 92
function test_get_payload_binary_none 104
function test_get_payload_binary_raw_bytes 109
function test_get_payload_binary_envelope 114
function test_get_payload_binary_envelope_compressed 119
function test_get_payload_binary_json_returns_utf8 126
function test_set_payload_none 136
function test_set_payload_json_dict 141
function test_set_payload_json_list 146
function test_set_payload_json_rejects_bytes 151
function test_set_payload_json_rejects_non_serializable 156
function test_set_payload_binary_wraps_in_envelope 164
function test_set_payload_binary_with_compression 173
function test_set_payload_binary_requires_bytes 184
function test_set_payload_binary_too_large_raises 189
function test_set_payload_json_too_large_raises 196
function test_is_json_dict 205
function test_is_json_list 210
function test_is_json_scalar 215
function test_is_json_false_for_bytes 220
function test_is_json_false_for_envelope 225
function test_is_json_false_for_none 230
function test_is_binary_for_bytes 235
function test_is_binary_for_bytearray 240
function test_is_binary_for_envelope 245
function test_is_binary_false_for_dict 250
function test_is_binary_false_for_none 255
function test_get_content_type_none 263
function test_get_content_type_raw_bytes 268
function test_get_content_type_envelope 273
function test_get_content_type_json 278
function test_get_payload_size_none 286
function test_get_payload_size_bytes 291
function test_get_payload_size_json 296
function test_get_payload_size_envelope_decoded 302
function test_get_payload_size_envelope_compressed_decoded 307
function test_validate_payload_size_none 316
function test_validate_payload_size_small_json 321
function test_validate_payload_size_small_bytes 326
function test_json_content_type_variants 334
function test_json_vendor_variant_treated_as_json 339
function test_text_json_treated_as_json 344
function test_non_json_content_type_treated_as_binary 349

tests/cxp/test_payload_extended.py

source · 82 tests · 585 lines

Extended tests for cxp.payload — edge cases, error paths, and boundary conditions.

Covers: cxp.exceptions, cxp.payload, core.packet/ (package)

Kind Name Line Description
function test_get_payload_list 55
function test_get_payload_string 60
function test_get_payload_int 65
function test_get_payload_float 70
function test_get_payload_bool 75
function test_get_payload_nested_dict 80
function test_get_payload_json_bytes_key_raises_invalid_packet_error 90 A dict with bytes keys is not JSON-serializable and triggers the except path.
function test_get_payload_json_transport_envelope 99
function test_get_payload_json_list 107
function test_get_payload_json_string 112
function test_get_payload_json_int 117
function test_get_payload_json_float 122
function test_get_payload_json_bool 127
function test_get_payload_binary_bytearray 137
function test_get_payload_binary_int 144
function test_get_payload_binary_string 150
function test_get_payload_binary_list 156
function test_set_payload_json_vendor_content_type 167
function test_set_payload_json_text_json_content_type 172
function test_set_payload_json_whitespace_content_type 177
function test_set_payload_binary_compress_false 182
function test_set_payload_binary_empty_bytes 189
function test_is_json_int 200
function test_is_json_float 205
function test_is_json_bool 210
function test_is_json_str 215
function test_is_json_bytearray 220
function test_is_json_empty_dict 225
function test_is_json_empty_list 230
function test_is_json_none 235
function test_is_json_tuple 240
function test_is_json_set 245
function test_is_binary_false_for_list 255
function test_is_binary_false_for_str 260
function test_is_binary_false_for_int 265
function test_is_binary_false_for_float 270
function test_is_binary_false_for_bool 275
function test_is_binary_false_for_none 280
function test_is_binary_true_for_bytearray 285
function test_get_content_type_list 295
function test_get_content_type_string 300
function test_get_content_type_int 305
function test_get_content_type_float 310
function test_get_content_type_bool 315
function test_get_content_type_bytearray 320
function test_get_content_type_envelope_default_content_type 325
function test_get_content_type_envelope_custom_content_type 335
function test_get_payload_size_list 351
function test_get_payload_size_string 357
function test_get_payload_size_int 363
function test_get_payload_size_float 369
function test_get_payload_size_bool 375
function test_get_payload_size_bytearray 381
function test_get_payload_size_empty_envelope 386
function test_get_payload_size_envelope_compressed_empty 396
function test_validate_payload_size_json_at_limit 415
function test_validate_payload_size_json_over_limit 425
function test_validate_payload_size_binary_at_limit 431
function test_validate_payload_size_binary_over_limit 436
function test_validate_payload_size_none 441
function test_is_json_content_type_exact 451
function test_is_json_content_type_vendor_suffix 455
function test_is_json_content_type_text_json 459
function test_is_json_content_type_uppercase 463
function test_is_json_content_type_mixed_case 467
function test_is_json_content_type_whitespace 471
function test_is_json_content_type_octet_stream 475
function test_is_json_content_type_image_png 479
function test_is_json_content_type_text_plain 483
function test_is_json_content_type_almost_json 487
function test_is_json_content_type_custom_plus_json 491
function test_set_json_payload_rejects_bytearray 500
function test_set_json_payload_rejects_bytes 506
function test_set_binary_payload_rejects_string 517
function test_set_binary_payload_rejects_int 523
function test_set_binary_payload_rejects_list 529
function test_json_roundtrip_dict 540
function test_json_roundtrip_list 547
function test_binary_roundtrip_uncompressed 553
function test_binary_roundtrip_compressed 560
function test_binary_roundtrip_bytearray 571
function test_payload_manager_instantiation 583

tests/cxp/test_postman_adapter.py

source · 32 tests · 320 lines

Tests for cxp.postman_adapter — PostmanAdapter queues and lifecycle.

Covers: cxp.exceptions, cxp.postman_adapter, core.packet/ (package)

Kind Name Line Description
function test_resolve_recipient_alias_unchanged 38
function test_resolve_recipient_display_name_maps 42
function test_resolve_recipient_unknown_passes_through 47
function test_resolve_recipient_empty_raises 51
function test_sort_key_priority_desc 59
function test_sort_key_same_priority_fifo 67
function test_enqueue_returns_queue_id 82
function test_enqueue_sets_queued_status 90
function test_enqueue_no_recipient_raises 97
function test_enqueue_expired_raises 105
function test_enqueue_acknowledged_raises 113
function test_enqueue_failed_raises 121
function test_enqueue_queue_size_grows 129
function test_enqueue_priority_ordering 139
function test_dequeue_empty_returns_none 152
function test_dequeue_returns_delivered_packet 157
function test_dequeue_discards_expired 166
function test_dequeue_higher_priority_first 178
function test_dequeue_by_display_name 188
function test_peek_empty_returns_none 200
function test_peek_doesnt_remove 205
function test_peek_skips_expired_head 215
function test_get_queue_size_empty 229
function test_get_all_queued_returns_copy 237
function test_acknowledge_delivered_packet 251
function test_acknowledge_non_delivered_raises 260
function test_reject_sets_failed 272
function test_reject_already_terminal_raises 281
function test_reject_acknowledged_raises 289
function test_history_populated_after_dequeue 300
function test_active_queues_reports_depth 308
function test_active_queues_excludes_empty 319

tests/cxp/test_priority.py

source · 7 tests · 101 lines

Tests for CXP priority handling.

Covers: cxp.exceptions, cxp.priority, core.packet/ (package)

Kind Name Line Description
class TestPriorityManager 30 Tests for PriorityManager.
method TestPriorityManager.test_sort_by_priority 33
method TestPriorityManager.test_get_priority_level_exact 60
method TestPriorityManager.test_get_priority_level_closest 68
method TestPriorityManager.test_get_priority_level_invalid 75
method TestPriorityManager.test_get_default_priority 82
method TestPriorityManager.test_validate_priority 89
method TestPriorityManager.test_clamp_priority 97

tests/cxp/test_prolog_bridge.py

source · 62 tests · 842 lines

Tests for cxp.prolog_bridge — PrologBridge with a real Prolog engine.

Covers: core.prolog_adapter, cxp.exceptions, cxp.prolog_bridge, core.packet/ (package)

Kind Name Line Description
function test_prolog_available_flag 131
function test_alias_to_atom_known 138
function test_alias_to_atom_unknown_lowercased 144
function test_atom_to_alias_known 148
function test_atom_to_alias_unknown_passthrough 153
function test_atom_to_alias_handles_non_string 157
function test_escape_prolog_string_single_quote 164
function test_escape_prolog_string_backslash 168
function test_escape_prolog_string_plain 172
function test_bridge_is_available 179
function test_bridge_rules_loaded 183
function test_bridge_without_rules_still_available 187
function test_bridge_missing_rules_file_is_handled 192
function test_bridge_resolves_rules_from_project 199
function test_bridge_ensures_dynamic_declared 208
function test_bridge_default_engine_uses_prolog_proxy 212 With no explicit engine, PrologBridge wires up the real
function test_packet_to_terms_field_order 230
function test_packet_to_terms_none_payload 258
function test_packet_to_terms_non_json_payload_falls_back 269
function test_packet_to_terms_string_timestamp 277
function test_packet_to_terms_falsy_timestamp_uses_now 285
function test_terms_to_packet_full_roundtrip 296
function test_terms_to_packet_invalid_json_payload 322
function test_terms_to_packet_invalid_timestamp_uses_now 342
function test_terms_to_packet_empty_timestamp_uses_now 362
function test_terms_to_packet_bad_priority_defaults_to_5 382
function test_terms_to_packet_bad_enums_fallback 401
function test_assert_and_retract_packet_roundtrip 424
function test_assert_packet_escapes_quotes 438
function test_assert_packet_without_engine_raises 453
function test_retract_packet_without_engine_raises 466
function test_query_by_thread_returns_empty_when_no_engine 480
function test_query_by_status_filters_delivery 490
function test_query_by_status_filters_work 514
function test_query_by_status_no_filters_returns_all_known 536
function test_query_by_status_returns_empty_when_no_engine 548
function test_validate_route_allowed 561
function test_validate_route_allowed_via_cd_to_qa 565
function test_validate_route_denied 569
function test_validate_route_unknown_pair_denied 595
function test_validate_route_without_rules_returns_false 600
function test_validate_route_malformed_atom_logs_and_returns_false 604
function test_validate_route_without_engine_returns_false 614
function test_validate_packet_valid 626
function test_validate_packet_invalid 633
function test_validate_packet_without_rules 640
function test_validate_packet_without_engine 647
function test_validate_packet_malformed_agent_logs_and_returns_false 659
function test_validate_packet_empty_payload_term 671
function test_build_packet_term_structure 681
function test_build_packet_term_large_payload_truncated 694
function test_interpret_valid 705
function test_interpret_invalid_with_reason 712
function test_interpret_invalid_bare 719
function test_ensure_dynamic_is_idempotent 729
function test_ensure_dynamic_without_engine 736
function test_load_rules_handles_consult_error 750
function test_assert_packet_engine_failure_wraps_error 805
function test_retract_packet_engine_failure_wraps_error 815
function test_query_by_thread_engine_failure_returns_empty 823
function test_query_by_status_engine_failure_returns_empty 829
function test_ensure_dynamic_both_fallback_paths_fail 835

tests/cxp/test_prolog_bridge_extended.py

source · 5 tests · 137 lines

Extended tests for cxp.prolog_bridge — error paths and edge cases.

Covers: core.prolog_adapter, cxp.prolog_bridge, core.packet/ (package)

Kind Name Line Description
function test_bridge_initializes_with_real_prolog 71 PrologBridge creates a working engine when Prolog is available.
function test_packet_to_terms_unserializable_payload_fallback 89 json.dumps TypeError/ValueError branch falls back to '{}'.
function test_ensure_dynamic_with_real_engine 101 _ensure_dynamic succeeds with a real janus-swi engine (via the adapter).
function test_build_packet_term_with_empty_payload 116 _build_packet_term emits 'empty' when payload is None/empty.
function test_build_packet_term_escapes_special_chars 126 _build_packet_term escapes quotes and backslashes in subject/body.

tests/cxp/test_receive_packets_per_consumer.py

source · 3 tests · 196 lines

Test Standards Compliance (see AGENTS.md § Test Standards):

Covers: cxp.proto_codec, cxp.servicer, cxp.transport

Kind Name Line Description
function test_two_consumers_each_receive_only_their_own 74 Two concurrent receive_packet drains each get ONLY their own stamped
function test_legacy_human_consumer_still_served 113 An unstamped reply (no metadata.reply_to, to_agent="HUMAN") still
function test_subscribe_no_longer_steals_other_consumers_replies 155 A live subscribe(agent_id=A) running concurrently must not consume

tests/cxp/test_reply_router.py

source · 14 tests · 345 lines

Test Standards Compliance (see AGENTS.md § Test Standards):

Covers: core.base.traces, core.tracing.tracer, cxp.reply_router, cxp.servicer

Kind Name Line Description
function test_route_prefers_metadata_reply_to_over_to_agent 75 metadata.reply_to wins over to_agent when both are present.
function test_unstamped_packet_routes_by_to_agent 89 No metadata.reply_to -> falls back to to_agent (legacy compatibility).
function test_unstamped_packet_with_empty_reply_to_falls_back_to_to_agent 100 An empty-string reply_to is treated as absent, not a literal key.
function test_default_key_used_when_neither_reply_to_nor_to_agent_present 110 Neither metadata.reply_to nor to_agent -> the module default key.
function test_per_consumer_isolation_no_cross_drain 121 Two consumers' replies land in two distinct queues -- no stealing.
function test_queue_for_returns_same_instance_across_calls 141 queue_for(id) returns the SAME Queue object every call (create-on-demand, cached).
function test_overflow_drops_oldest_and_traces 151 max_queue=3, 5 packets routed -> oldest 2 dropped, newest 3 retained, traced.
function test_idle_queue_evicted_after_ttl 172 An INACTIVE consumer's queue is evicted once idle beyond idle_ttl_s.
function test_active_drain_never_evicted 199 A consumer with an open drain lease survives past its idle TTL.
function test_route_refreshes_activity 224 route() to an existing key refreshes last_activity, resetting its idle clock.
function test_cap_evicts_oldest_idle_inactive_first 249 Over max_consumers, the OLDEST-idle INACTIVE entries are evicted first.
function test_eviction_traced_with_dropped_count 283 Idle-TTL eviction logs a traced warning naming the key and dropped count.
function test_close_drain_on_unknown_consumer_is_a_noop 308 close_drain on a consumer id with no entry is a documented no-op.
function test_env_float_and_env_int_fall_back_on_invalid_value 325 CXPServicer's F7 tunable resolution must not crash on a malformed

tests/cxp/test_router.py

source · 21 tests · 184 lines

Tests for cxp.router — CXPRouter, routing decisions, governance.

Covers: cxp.exceptions, cxp.router, cxp.types, core.packet/ (package)

Kind Name Line Description
function test_router_default_init 28
function test_router_non_hub_can_reach_postman 33
function test_router_non_hub_can_reach_orchestrator 37
function test_router_orchestrator_reaches_everyone 41
function test_router_postman_reaches_everyone 49
function test_router_non_hub_blocked_from_peer 57
function test_register_route_adds 65
function test_register_route_for_new_agent 70
function test_unregister_route_removes 75
function test_unregister_nonexistent_is_noop 81
function test_get_routes_for_returns_sorted 89
function test_get_routes_for_unknown 94
function test_get_all_routes_returns_sorted 98
function test_route_succeeds_on_valid_route 109
function test_route_missing_from_raises 117
function test_route_missing_to_raises 125
function test_route_no_route_raises 133
function test_route_allows_when_governance_approves 159
function test_route_rejects_when_governance_denies 166
function test_route_rejects_when_governance_raises 174
function test_is_valid_route_unknown_agents 183

tests/cxp/test_schema.py

source · 29 tests · 283 lines

Tests for cxp.schema — CXP_PACKET_SCHEMA and SchemaRegistry.

Covers: cxp.schema, core.packet/ (package)

Kind Name Line Description
function test_packet_schema_is_object 30
function test_packet_schema_required_fields_present 34
function test_packet_schema_additional_properties_false 49
function test_packet_schema_priority_range 53
function test_packet_schema_delivery_status_enum 59
function test_packet_schema_work_status_enum 64
function test_registry_has_cxp_packet_preregistered 72
function test_registry_get_schema 76
function test_registry_get_missing_returns_none 80
function test_register_schema_adds_entry 87
function test_register_schema_overwrites 93
function test_list_schemas_sorted 99
function test_validate_missing_schema_returns_false 109
function test_validate_accepts_valid_packet 115
function test_validate_missing_required_fields 130
function test_validate_type_mismatch 145
function test_validate_enum_violation 156
function test_validate_pattern_violation 167
function test_validate_pattern_match 178
function test_validate_max_length 188
function test_validate_min_length 199
function test_validate_minimum_violation 210
function test_validate_maximum_violation 221
function test_validate_additional_properties_false 232
function test_validate_union_type 244
function test_validate_bool_not_integer 260
function test_check_type_unknown_passes 271
function test_check_type_array 275
function test_check_type_number_accepts_float 280

tests/cxp/test_serializer.py

source · 10 tests · 90 lines

Tests for cxp.serializer.

Covers: cxp.serializer, core.packet/ (package)

Kind Name Line Description
class TestCXPSerializer 29
method TestCXPSerializer.test_init_defaults 30
method TestCXPSerializer.test_init_with_config 34
method TestCXPSerializer.test_to_json 38
method TestCXPSerializer.test_from_json 47
method TestCXPSerializer.test_to_dict 56
method TestCXPSerializer.test_from_dict 63
method TestCXPSerializer.test_serialize_alias 70
method TestCXPSerializer.test_deserialize_alias 75
method TestCXPSerializer.test_serialize_to_dict_alias 81
method TestCXPSerializer.test_deserialize_from_dict_alias 86

tests/cxp/test_session_adapter.py

source · 26 tests · 224 lines

Tests for cxp.session_adapter — SessionAdapter session isolation.

Covers: cxp.exceptions, cxp.session_adapter, core.packet/ (package)

Kind Name Line Description
function test_default_unbound 35
function test_init_with_session_id 41
function test_bind_session_sets_id 50
function test_bind_empty_raises 56
function test_unbind_clears_id 61
function test_unbind_preserves_packets 67
function test_rebind_new_id 75
function test_tag_packet_sets_metadata 83
function test_tag_packet_returns_same_instance 88
function test_tag_packet_unbound_raises 93
function test_validate_isolation_returns_true_for_matching 101
function test_validate_isolation_false_for_mismatched 106
function test_validate_isolation_false_for_untagged 111
function test_validate_isolation_unbound_returns_false 115
function test_add_packet_stores 123
function test_add_packet_unbound_raises 129
function test_add_packet_wrong_session_raises 134
function test_add_packet_without_tag_raises 140
function test_get_session_packets_returns_copy 149
function test_get_session_packets_empty 157
function test_clear_session_empties 164
function test_clear_session_preserves_binding 171
function test_stats_empty 180
function test_stats_counts_by_status 188
function test_stats_counts_by_type 200
function test_stats_mixed_statuses 213

tests/cxp/test_thread_store.py

source · 8 tests · 89 lines

Tests for CXP thread store.

Covers: cxp.exceptions, cxp.thread_store, cxp.types, core.packet/ (package)

Kind Name Line Description
class TestThreadStore 31 Tests for ThreadStore.
method TestThreadStore.test_init 34
method TestThreadStore.test_save_and_load 38
method TestThreadStore.test_load_missing_raises 47
method TestThreadStore.test_delete_thread 52
method TestThreadStore.test_delete_missing_raises 62
method TestThreadStore.test_list_threads 67
method TestThreadStore.test_thread_exists 74
method TestThreadStore.test_save_overwrites 80

tests/cxp/test_threads.py

source · 30 tests · 308 lines

Tests for cxp.threads — ThreadManager lifecycle and operations.

Covers: cxp.exceptions, cxp.thread_store, cxp.threads, cxp.types, core.packet/ (package)

Kind Name Line Description
function test_create_thread_returns_thread_id 49
function test_create_thread_sets_metadata 54
function test_create_thread_when_no_thread_id 63
function test_create_thread_duplicate_raises 73
function test_create_thread_persists_to_store 85
function test_add_to_thread_appends 96
function test_add_to_thread_updates_message_count 104
function test_add_to_thread_tracks_new_participant 111
function test_add_to_thread_missing_raises 120
function test_add_to_resolved_thread_raises 125
function test_add_to_archived_thread_raises 132
function test_get_thread_packets_chronological_order 143
function test_get_thread_packets_missing_raises 156
function test_get_thread_metadata_missing_raises 164
function test_close_thread_sets_resolved 172
function test_close_thread_missing_raises 179
function test_close_archived_thread_raises 184
function test_reopen_thread_sets_active 195
function test_reopen_archived_thread_raises 203
function test_reopen_missing_raises 211
function test_archive_stale_threads_archives_old 219
function test_archive_stale_threads_skips_recent 229
function test_archive_stale_threads_skips_already_archived 235
function test_archive_stale_threads_includes_resolved 244
function test_list_active_threads_empty 259
function test_list_active_threads_only_active 263
function test_get_thread_count_zero 276
function test_get_thread_count_increments 280
function test_thread_exists 290
function test_uses_provided_store 299

tests/cxp/test_transport.py

source · 5 tests · 79 lines

Tests for the CXP transport factory (cxp.transport).

Covers: cxp.direct_cxp_adapter, cxp.transport

Kind Name Line Description
function test_defaults_to_cxpt_when_unset 37
function test_selects_cxpt_when_set_explicitly 43
function test_transport_value_is_normalised 50
function test_retired_grpc_value_is_rejected_not_silently_substituted 55 A stale CXP_TRANSPORT=grpc must fail loudly at construction.
function test_unknown_value_is_rejected 72

tests/cxp/test_types.py

source · 11 tests · 135 lines

Tests for CXP types.

Covers: cxp.types

Kind Name Line Description
class TestCXPConstants 33 Tests for CXP type constants.
method TestCXPConstants.test_volk_aliases 36
method TestCXPConstants.test_volk_roles 40
method TestCXPConstants.test_thread_status_values 44
class TestThreadMetadata 50 Tests for ThreadMetadata.
method TestThreadMetadata.test_default_values 53
method TestThreadMetadata.test_add_participant 60
method TestThreadMetadata.test_touch 69
method TestThreadMetadata.test_to_dict 76
method TestThreadMetadata.test_from_dict 84
method TestThreadMetadata.test_from_dict_with_z_suffix 103
class TestRoutingResult 115 Tests for RoutingResult.
method TestRoutingResult.test_to_dict_basic 118
method TestRoutingResult.test_to_dict_with_priority 127

tests/cxp/test_validator.py

source · 27 tests · 245 lines

Tests for cxp.validator — CXPValidator and ValidationRule.

Covers: cxp.validator, core.packet/ (package)

Kind Name Line Description
function test_validation_rule_fields 39
function test_validator_default_init 53
function test_validator_custom_config 58
function test_validate_valid_packet_returns_success 66
function test_validate_result_includes_packet_id 73
function test_validate_invalid_sender_format 78
function test_validate_invalid_recipient_format 85
function test_validate_sender_equals_recipient 92
function test_validate_subject_empty 99
function test_validate_subject_too_long 106
function test_validate_priority_out_of_range_high 114
function test_validate_priority_negative 121
function test_validate_payload_none_ok 127
function test_validate_payload_dict_ok 134
function test_validate_payload_bytes_ok 140
function test_validate_payload_string_fails 146
function test_add_rule_runs_in_validate 157
function test_add_rule_failure_recorded 169
function test_add_rule_warning_message 175
function test_remove_rule_removes 181
function test_validate_catches_rule_exception 188
function test_register_validator_passes_when_true 201
function test_register_validator_fails_when_false 207
function test_validate_schema_delegates 217
function test_validate_schema_failure 227
function test_priority_constants 239
function test_subject_max_length 244

tests/cxp/test_version.py

source · 15 tests · 104 lines

Tests for CXP ProtocolVersion.

Covers: cxp.version

Kind Name Line Description
class TestProtocolVersion 32 Tests for ProtocolVersion.
method TestProtocolVersion.test_init_default 35
method TestProtocolVersion.test_init_custom 41
method TestProtocolVersion.test_init_invalid 47
method TestProtocolVersion.test_str 53
method TestProtocolVersion.test_repr 56
method TestProtocolVersion.test_eq 59
method TestProtocolVersion.test_eq_non_protocol_version 63
method TestProtocolVersion.test_comparison 66
method TestProtocolVersion.test_comparison_non_protocol_version 72
method TestProtocolVersion.test_is_compatible_with 75
method TestProtocolVersion.test_to_dict 85
method TestProtocolVersion.test_from_string 92
method TestProtocolVersion.test_hash 96
method TestProtocolVersion.test_current_version 99
method TestProtocolVersion.test_parse_version 102

tests/cxp/test_version_compat.py

source · 8 tests · 67 lines

Tests for CXP version compatibility.

Covers: cxp.version_compat

Kind Name Line Description
class TestVersionChecker 28 Tests for VersionChecker.
method TestVersionChecker.test_compatible 31
method TestVersionChecker.test_warn 37
method TestVersionChecker.test_incompatible 42
method TestVersionChecker.test_negotiate_same 48
method TestVersionChecker.test_negotiate_different_minor 52
method TestVersionChecker.test_negotiate_different_patch 56
method TestVersionChecker.test_negotiate_incompatible_raises 60
method TestVersionChecker.test_get_supported_versions 65

tests/cxp/test_websocket.py

source · 26 tests · 707 lines

Test Standards Compliance (see AGENTS.md § Test Standards):

Covers: cxp.ws_client, cxp.ws_server

Kind Name Line Description
function test_ws_client_connect_and_disconnect 60 Real echo server + WSClient — verify connected state flips correctly.
function test_ws_client_send_and_receive 92 Server echoes a packet_sent reply — WSClient.send_packet returns it.
function test_ws_server_start_and_stop 144 WSServer starts, greets the client, answers ping, then stops cleanly.
function test_ws_client_subscribe 167 WSClient.subscribe sends subscribe and parses subscribed response.
function test_ws_client_acknowledge 198 WSClient.acknowledge sends ack and parses acknowledged response.
function test_ws_client_ping 227 WSClient.ping sends ping and parses pong response.
function test_ws_client_ping_not_connected 256 WSClient.ping returns False when not connected.
function test_ws_client_process_message_packet_sent 266 _process_message handles packet_sent type.
function test_ws_client_process_message_pong 276 _process_message handles pong type.
function test_ws_client_process_message_subscribed 284 _process_message handles subscribed type.
function test_ws_client_process_message_packet 292 _process_message handles packet type — puts inner packet dict.
function test_ws_client_send_auto_connect 304 WSClient.send_packet auto-connects if not connected.
function test_ws_client_process_message_error 346 WSClient._process_message handles error type.
function test_ws_client_receive_loop_connection_closed 361 _receive_loop handles websockets ConnectionClosed gracefully.
function test_ws_server_broadcast 390 WSServer.broadcast sends the packet to every connected client.
function test_ws_handler_invalid_json 433 CXPWebSocketHandler.handle returns error for invalid JSON.
function test_ws_handler_unknown_message_type 451 CXPWebSocketHandler.handle returns error for unknown message type.
function test_ws_handler_send_packet_via_handler 468 CXPWebSocketHandler.handle processes send_packet messages.
function test_ws_handler_subscribe_via_handler 507 CXPWebSocketHandler.handle processes subscribe messages.
function test_ws_handler_acknowledge_via_handler 531 CXPWebSocketHandler.handle processes acknowledge messages.
function test_ws_handler_connection_cleanup 555 CXPWebSocketHandler.handle cleans up subscriptions on disconnect.
function test_ws_handler_send_packet_no_handler_defaults_success 591 _handle_send_packet defaults to {"success": True} when no packet_handler is set.
function test_ws_handler_send_packet_async_handler_is_awaited 616 _handle_send_packet awaits a coroutine-returning packet_handler.
function test_ws_handler_process_message_generic_exception 651 _process_message's generic except branch reports a raising packet_handler's error.
function test_ws_server_broadcast_noop_before_start 682 WSServer.broadcast returns immediately when the server hasn't started.
function test_ws_server_serve_forever 692

tests/cxp/test_work_status.py

source · 18 tests · 150 lines

Tests for CXP work status tracking.

Covers: cxp.exceptions, cxp.work_status, core.packet/ (package)

Kind Name Line Description
class TestValidateWorkTransition 30 Tests for validate_work_transition.
method TestValidateWorkTransition.test_pending_to_in_progress 33
method TestValidateWorkTransition.test_in_progress_to_resolved 38
method TestValidateWorkTransition.test_in_progress_to_pending 44
method TestValidateWorkTransition.test_resolved_to_archived 49
method TestValidateWorkTransition.test_pending_to_resolved 54
method TestValidateWorkTransition.test_archived_to_any 59
class TestWorkTracker 65 Tests for WorkTracker.
method TestWorkTracker.test_init 68
method TestWorkTracker.test_set_status_valid 73
method TestWorkTracker.test_set_status_invalid_raises 79
method TestWorkTracker.test_get_history 86
method TestWorkTracker.test_get_history_empty 94
method TestWorkTracker.test_start_work 99
method TestWorkTracker.test_resolve_work 105
method TestWorkTracker.test_archive_work 112
method TestWorkTracker.test_requeue_work 120
method TestWorkTracker.test_get_work_duration 127
method TestWorkTracker.test_get_work_duration_none 136
method TestWorkTracker.test_get_metadata 141

tests/cxp/test_ws_client.py

source · 23 tests · 510 lines

Tests for cxp.ws_client.

Covers: cxp.ws_client

Kind Name Line Description
function test_ws_client_connect_and_disconnect 102 Real server greeting flips _connected/_client_id; disconnect flips back.
function test_ws_client_send_packet_success 133 Server echoes a packet_sent reply — send_packet returns the receipt.
function test_ws_client_send_packet_auto_connects 175 send_packet auto-connects when called before connect().
function test_ws_client_subscribe_success 214 subscribe() sends subscribe and parses the subscribed response.
function test_ws_client_subscribe_auto_connects 238 subscribe() auto-connects when called before connect().
function test_ws_client_acknowledge_success 267 acknowledge() sends acknowledge and parses the acknowledged response.
function test_ws_client_acknowledge_auto_connects 290 acknowledge() auto-connects when called before connect().
function test_ws_client_ping_success 319 ping() returns True when the server answers with pong.
function test_ws_client_ping_timeout_returns_false 342 ping() returns False if no pong arrives within its 5s timeout.
function test_ws_client_process_message_packet_queues_inner_packet 371 _process_message puts the inner packet dict (not the envelope) on 'packet'.
function test_ws_client_process_message_error_logs_and_queues 380 _process_message logs and queues the envelope for an 'error' message.
function test_ws_client_receive_loop_abnormal_close_logs_connection_closed 397 An abnormal close (server crash -> code 1011) raises ConnectionClosedError
function test_ws_client_receive_loop_generic_exception_logs_error 423 A malformed (non-JSON) message crashes _process_message inside the
function test_ws_client_receive_packets_filters_and_yields 455 receive_packets() skips non-'packet' queue entries and yields 'packet' ones.
function test_ws_client_receive_packets_timeout_then_continues 471 An empty queue trips the 1s wait_for TimeoutError, which is swallowed
function test_ws_client_receive_packets_cancelled_breaks_loop 493 Cancelling the consuming task while receive_packets() awaits the queue
class TestWSClientConfig 34
method TestWSClientConfig.test_defaults 35
method TestWSClientConfig.test_custom_values 45
class TestWSClient 51
method TestWSClient.test_init_default_config 52
method TestWSClient.test_init_with_config 60
method TestWSClient.test_subscriptions_empty 65
method TestWSClient.test_message_queue_exists 69
method TestWSClient.test_ping_not_connected 73

Support files

Fixtures, package markers and helpers without test functions.