omnibase_infra 0.2.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (833) hide show
  1. omnibase_infra/__init__.py +101 -0
  2. omnibase_infra/adapters/adapter_onex_tool_execution.py +451 -0
  3. omnibase_infra/capabilities/__init__.py +15 -0
  4. omnibase_infra/capabilities/capability_inference_rules.py +211 -0
  5. omnibase_infra/capabilities/contract_capability_extractor.py +221 -0
  6. omnibase_infra/capabilities/intent_type_extractor.py +160 -0
  7. omnibase_infra/cli/__init__.py +1 -0
  8. omnibase_infra/cli/commands.py +216 -0
  9. omnibase_infra/clients/__init__.py +0 -0
  10. omnibase_infra/configs/widget_mapping.yaml +176 -0
  11. omnibase_infra/constants_topic_patterns.py +26 -0
  12. omnibase_infra/contracts/handlers/filesystem/handler_contract.yaml +264 -0
  13. omnibase_infra/contracts/handlers/mcp/handler_contract.yaml +141 -0
  14. omnibase_infra/decorators/__init__.py +29 -0
  15. omnibase_infra/decorators/allow_any.py +109 -0
  16. omnibase_infra/dlq/__init__.py +90 -0
  17. omnibase_infra/dlq/constants_dlq.py +57 -0
  18. omnibase_infra/dlq/models/__init__.py +26 -0
  19. omnibase_infra/dlq/models/enum_replay_status.py +37 -0
  20. omnibase_infra/dlq/models/model_dlq_replay_record.py +135 -0
  21. omnibase_infra/dlq/models/model_dlq_tracking_config.py +184 -0
  22. omnibase_infra/dlq/service_dlq_tracking.py +611 -0
  23. omnibase_infra/enums/__init__.py +132 -0
  24. omnibase_infra/enums/enum_any_type_violation.py +104 -0
  25. omnibase_infra/enums/enum_backend_type.py +27 -0
  26. omnibase_infra/enums/enum_capture_outcome.py +42 -0
  27. omnibase_infra/enums/enum_capture_state.py +88 -0
  28. omnibase_infra/enums/enum_chain_violation_type.py +119 -0
  29. omnibase_infra/enums/enum_circuit_state.py +51 -0
  30. omnibase_infra/enums/enum_confirmation_event_type.py +27 -0
  31. omnibase_infra/enums/enum_consumer_group_purpose.py +92 -0
  32. omnibase_infra/enums/enum_contract_type.py +84 -0
  33. omnibase_infra/enums/enum_dedupe_strategy.py +46 -0
  34. omnibase_infra/enums/enum_dispatch_status.py +191 -0
  35. omnibase_infra/enums/enum_environment.py +46 -0
  36. omnibase_infra/enums/enum_execution_shape_violation.py +103 -0
  37. omnibase_infra/enums/enum_handler_error_type.py +111 -0
  38. omnibase_infra/enums/enum_handler_loader_error.py +178 -0
  39. omnibase_infra/enums/enum_handler_source_mode.py +86 -0
  40. omnibase_infra/enums/enum_handler_source_type.py +87 -0
  41. omnibase_infra/enums/enum_handler_type.py +77 -0
  42. omnibase_infra/enums/enum_handler_type_category.py +61 -0
  43. omnibase_infra/enums/enum_infra_transport_type.py +73 -0
  44. omnibase_infra/enums/enum_introspection_reason.py +154 -0
  45. omnibase_infra/enums/enum_kafka_acks.py +99 -0
  46. omnibase_infra/enums/enum_message_category.py +213 -0
  47. omnibase_infra/enums/enum_node_archetype.py +74 -0
  48. omnibase_infra/enums/enum_node_output_type.py +185 -0
  49. omnibase_infra/enums/enum_non_retryable_error_category.py +224 -0
  50. omnibase_infra/enums/enum_policy_type.py +32 -0
  51. omnibase_infra/enums/enum_registration_state.py +261 -0
  52. omnibase_infra/enums/enum_registration_status.py +33 -0
  53. omnibase_infra/enums/enum_registry_response_status.py +28 -0
  54. omnibase_infra/enums/enum_response_status.py +26 -0
  55. omnibase_infra/enums/enum_retry_error_category.py +98 -0
  56. omnibase_infra/enums/enum_security_rule_id.py +103 -0
  57. omnibase_infra/enums/enum_selection_strategy.py +91 -0
  58. omnibase_infra/enums/enum_topic_standard.py +42 -0
  59. omnibase_infra/enums/enum_validation_severity.py +78 -0
  60. omnibase_infra/errors/__init__.py +160 -0
  61. omnibase_infra/errors/error_architecture_violation.py +152 -0
  62. omnibase_infra/errors/error_binding_resolution.py +128 -0
  63. omnibase_infra/errors/error_chain_propagation.py +188 -0
  64. omnibase_infra/errors/error_compute_registry.py +95 -0
  65. omnibase_infra/errors/error_consul.py +132 -0
  66. omnibase_infra/errors/error_container_wiring.py +243 -0
  67. omnibase_infra/errors/error_event_bus_registry.py +105 -0
  68. omnibase_infra/errors/error_infra.py +610 -0
  69. omnibase_infra/errors/error_message_type_registry.py +101 -0
  70. omnibase_infra/errors/error_policy_registry.py +115 -0
  71. omnibase_infra/errors/error_vault.py +123 -0
  72. omnibase_infra/event_bus/__init__.py +72 -0
  73. omnibase_infra/event_bus/configs/kafka_event_bus_config.yaml +84 -0
  74. omnibase_infra/event_bus/event_bus_inmemory.py +797 -0
  75. omnibase_infra/event_bus/event_bus_kafka.py +1716 -0
  76. omnibase_infra/event_bus/mixin_kafka_broadcast.py +180 -0
  77. omnibase_infra/event_bus/mixin_kafka_dlq.py +771 -0
  78. omnibase_infra/event_bus/models/__init__.py +29 -0
  79. omnibase_infra/event_bus/models/config/__init__.py +20 -0
  80. omnibase_infra/event_bus/models/config/model_kafka_event_bus_config.py +693 -0
  81. omnibase_infra/event_bus/models/model_dlq_event.py +206 -0
  82. omnibase_infra/event_bus/models/model_dlq_metrics.py +304 -0
  83. omnibase_infra/event_bus/models/model_event_headers.py +115 -0
  84. omnibase_infra/event_bus/models/model_event_message.py +60 -0
  85. omnibase_infra/event_bus/testing/__init__.py +26 -0
  86. omnibase_infra/event_bus/testing/adapter_protocol_event_publisher_inmemory.py +418 -0
  87. omnibase_infra/event_bus/testing/model_publisher_metrics.py +64 -0
  88. omnibase_infra/event_bus/topic_constants.py +376 -0
  89. omnibase_infra/handlers/__init__.py +82 -0
  90. omnibase_infra/handlers/filesystem/__init__.py +48 -0
  91. omnibase_infra/handlers/filesystem/enum_file_system_operation.py +35 -0
  92. omnibase_infra/handlers/filesystem/model_file_system_request.py +298 -0
  93. omnibase_infra/handlers/filesystem/model_file_system_result.py +166 -0
  94. omnibase_infra/handlers/handler_consul.py +795 -0
  95. omnibase_infra/handlers/handler_db.py +1046 -0
  96. omnibase_infra/handlers/handler_filesystem.py +1478 -0
  97. omnibase_infra/handlers/handler_graph.py +2015 -0
  98. omnibase_infra/handlers/handler_http.py +926 -0
  99. omnibase_infra/handlers/handler_intent.py +387 -0
  100. omnibase_infra/handlers/handler_manifest_persistence.contract.yaml +184 -0
  101. omnibase_infra/handlers/handler_manifest_persistence.py +1539 -0
  102. omnibase_infra/handlers/handler_mcp.py +1430 -0
  103. omnibase_infra/handlers/handler_qdrant.py +1076 -0
  104. omnibase_infra/handlers/handler_vault.py +428 -0
  105. omnibase_infra/handlers/mcp/__init__.py +19 -0
  106. omnibase_infra/handlers/mcp/adapter_onex_to_mcp.py +446 -0
  107. omnibase_infra/handlers/mcp/protocols.py +178 -0
  108. omnibase_infra/handlers/mcp/transport_streamable_http.py +352 -0
  109. omnibase_infra/handlers/mixins/__init__.py +47 -0
  110. omnibase_infra/handlers/mixins/mixin_consul_initialization.py +349 -0
  111. omnibase_infra/handlers/mixins/mixin_consul_kv.py +338 -0
  112. omnibase_infra/handlers/mixins/mixin_consul_service.py +542 -0
  113. omnibase_infra/handlers/mixins/mixin_consul_topic_index.py +585 -0
  114. omnibase_infra/handlers/mixins/mixin_vault_initialization.py +338 -0
  115. omnibase_infra/handlers/mixins/mixin_vault_retry.py +412 -0
  116. omnibase_infra/handlers/mixins/mixin_vault_secrets.py +450 -0
  117. omnibase_infra/handlers/mixins/mixin_vault_token.py +365 -0
  118. omnibase_infra/handlers/models/__init__.py +286 -0
  119. omnibase_infra/handlers/models/consul/__init__.py +81 -0
  120. omnibase_infra/handlers/models/consul/enum_consul_operation_type.py +57 -0
  121. omnibase_infra/handlers/models/consul/model_consul_deregister_payload.py +51 -0
  122. omnibase_infra/handlers/models/consul/model_consul_handler_config.py +153 -0
  123. omnibase_infra/handlers/models/consul/model_consul_handler_payload.py +89 -0
  124. omnibase_infra/handlers/models/consul/model_consul_kv_get_found_payload.py +55 -0
  125. omnibase_infra/handlers/models/consul/model_consul_kv_get_not_found_payload.py +49 -0
  126. omnibase_infra/handlers/models/consul/model_consul_kv_get_recurse_payload.py +50 -0
  127. omnibase_infra/handlers/models/consul/model_consul_kv_item.py +33 -0
  128. omnibase_infra/handlers/models/consul/model_consul_kv_put_payload.py +41 -0
  129. omnibase_infra/handlers/models/consul/model_consul_register_payload.py +53 -0
  130. omnibase_infra/handlers/models/consul/model_consul_retry_config.py +66 -0
  131. omnibase_infra/handlers/models/consul/model_payload_consul.py +66 -0
  132. omnibase_infra/handlers/models/consul/registry_payload_consul.py +214 -0
  133. omnibase_infra/handlers/models/graph/__init__.py +35 -0
  134. omnibase_infra/handlers/models/graph/enum_graph_operation_type.py +20 -0
  135. omnibase_infra/handlers/models/graph/model_graph_execute_payload.py +38 -0
  136. omnibase_infra/handlers/models/graph/model_graph_handler_config.py +54 -0
  137. omnibase_infra/handlers/models/graph/model_graph_handler_payload.py +44 -0
  138. omnibase_infra/handlers/models/graph/model_graph_query_payload.py +40 -0
  139. omnibase_infra/handlers/models/graph/model_graph_record.py +22 -0
  140. omnibase_infra/handlers/models/http/__init__.py +50 -0
  141. omnibase_infra/handlers/models/http/enum_http_operation_type.py +29 -0
  142. omnibase_infra/handlers/models/http/model_http_body_content.py +45 -0
  143. omnibase_infra/handlers/models/http/model_http_get_payload.py +88 -0
  144. omnibase_infra/handlers/models/http/model_http_handler_payload.py +90 -0
  145. omnibase_infra/handlers/models/http/model_http_post_payload.py +88 -0
  146. omnibase_infra/handlers/models/http/model_payload_http.py +66 -0
  147. omnibase_infra/handlers/models/http/registry_payload_http.py +212 -0
  148. omnibase_infra/handlers/models/mcp/__init__.py +23 -0
  149. omnibase_infra/handlers/models/mcp/enum_mcp_operation_type.py +24 -0
  150. omnibase_infra/handlers/models/mcp/model_mcp_handler_config.py +40 -0
  151. omnibase_infra/handlers/models/mcp/model_mcp_tool_call.py +32 -0
  152. omnibase_infra/handlers/models/mcp/model_mcp_tool_result.py +45 -0
  153. omnibase_infra/handlers/models/model_consul_handler_response.py +96 -0
  154. omnibase_infra/handlers/models/model_db_describe_response.py +83 -0
  155. omnibase_infra/handlers/models/model_db_query_payload.py +95 -0
  156. omnibase_infra/handlers/models/model_db_query_response.py +60 -0
  157. omnibase_infra/handlers/models/model_filesystem_config.py +98 -0
  158. omnibase_infra/handlers/models/model_filesystem_delete_payload.py +54 -0
  159. omnibase_infra/handlers/models/model_filesystem_delete_result.py +77 -0
  160. omnibase_infra/handlers/models/model_filesystem_directory_entry.py +75 -0
  161. omnibase_infra/handlers/models/model_filesystem_ensure_directory_payload.py +54 -0
  162. omnibase_infra/handlers/models/model_filesystem_ensure_directory_result.py +60 -0
  163. omnibase_infra/handlers/models/model_filesystem_list_directory_payload.py +60 -0
  164. omnibase_infra/handlers/models/model_filesystem_list_directory_result.py +68 -0
  165. omnibase_infra/handlers/models/model_filesystem_read_payload.py +62 -0
  166. omnibase_infra/handlers/models/model_filesystem_read_result.py +61 -0
  167. omnibase_infra/handlers/models/model_filesystem_write_payload.py +70 -0
  168. omnibase_infra/handlers/models/model_filesystem_write_result.py +55 -0
  169. omnibase_infra/handlers/models/model_graph_handler_response.py +98 -0
  170. omnibase_infra/handlers/models/model_handler_response.py +103 -0
  171. omnibase_infra/handlers/models/model_http_handler_response.py +101 -0
  172. omnibase_infra/handlers/models/model_manifest_metadata.py +75 -0
  173. omnibase_infra/handlers/models/model_manifest_persistence_config.py +62 -0
  174. omnibase_infra/handlers/models/model_manifest_query_payload.py +90 -0
  175. omnibase_infra/handlers/models/model_manifest_query_result.py +97 -0
  176. omnibase_infra/handlers/models/model_manifest_retrieve_payload.py +44 -0
  177. omnibase_infra/handlers/models/model_manifest_retrieve_result.py +98 -0
  178. omnibase_infra/handlers/models/model_manifest_store_payload.py +47 -0
  179. omnibase_infra/handlers/models/model_manifest_store_result.py +67 -0
  180. omnibase_infra/handlers/models/model_operation_context.py +187 -0
  181. omnibase_infra/handlers/models/model_qdrant_handler_response.py +98 -0
  182. omnibase_infra/handlers/models/model_retry_state.py +162 -0
  183. omnibase_infra/handlers/models/model_vault_handler_response.py +98 -0
  184. omnibase_infra/handlers/models/qdrant/__init__.py +44 -0
  185. omnibase_infra/handlers/models/qdrant/enum_qdrant_operation_type.py +26 -0
  186. omnibase_infra/handlers/models/qdrant/model_qdrant_collection_payload.py +42 -0
  187. omnibase_infra/handlers/models/qdrant/model_qdrant_delete_payload.py +36 -0
  188. omnibase_infra/handlers/models/qdrant/model_qdrant_handler_config.py +42 -0
  189. omnibase_infra/handlers/models/qdrant/model_qdrant_handler_payload.py +54 -0
  190. omnibase_infra/handlers/models/qdrant/model_qdrant_search_payload.py +42 -0
  191. omnibase_infra/handlers/models/qdrant/model_qdrant_search_result.py +30 -0
  192. omnibase_infra/handlers/models/qdrant/model_qdrant_upsert_payload.py +36 -0
  193. omnibase_infra/handlers/models/vault/__init__.py +69 -0
  194. omnibase_infra/handlers/models/vault/enum_vault_operation_type.py +35 -0
  195. omnibase_infra/handlers/models/vault/model_payload_vault.py +66 -0
  196. omnibase_infra/handlers/models/vault/model_vault_delete_payload.py +57 -0
  197. omnibase_infra/handlers/models/vault/model_vault_handler_config.py +148 -0
  198. omnibase_infra/handlers/models/vault/model_vault_handler_payload.py +101 -0
  199. omnibase_infra/handlers/models/vault/model_vault_list_payload.py +58 -0
  200. omnibase_infra/handlers/models/vault/model_vault_renew_token_payload.py +67 -0
  201. omnibase_infra/handlers/models/vault/model_vault_retry_config.py +66 -0
  202. omnibase_infra/handlers/models/vault/model_vault_secret_payload.py +106 -0
  203. omnibase_infra/handlers/models/vault/model_vault_write_payload.py +66 -0
  204. omnibase_infra/handlers/models/vault/registry_payload_vault.py +213 -0
  205. omnibase_infra/handlers/registration_storage/__init__.py +43 -0
  206. omnibase_infra/handlers/registration_storage/handler_registration_storage_mock.py +392 -0
  207. omnibase_infra/handlers/registration_storage/handler_registration_storage_postgres.py +922 -0
  208. omnibase_infra/handlers/registration_storage/models/__init__.py +23 -0
  209. omnibase_infra/handlers/registration_storage/models/model_delete_registration_request.py +58 -0
  210. omnibase_infra/handlers/registration_storage/models/model_update_registration_request.py +73 -0
  211. omnibase_infra/handlers/registration_storage/protocol_registration_persistence.py +191 -0
  212. omnibase_infra/handlers/service_discovery/__init__.py +43 -0
  213. omnibase_infra/handlers/service_discovery/handler_service_discovery_consul.py +1051 -0
  214. omnibase_infra/handlers/service_discovery/handler_service_discovery_mock.py +258 -0
  215. omnibase_infra/handlers/service_discovery/models/__init__.py +22 -0
  216. omnibase_infra/handlers/service_discovery/models/model_discovery_result.py +64 -0
  217. omnibase_infra/handlers/service_discovery/models/model_registration_result.py +138 -0
  218. omnibase_infra/handlers/service_discovery/models/model_service_info.py +109 -0
  219. omnibase_infra/handlers/service_discovery/protocol_discovery_operations.py +170 -0
  220. omnibase_infra/idempotency/__init__.py +94 -0
  221. omnibase_infra/idempotency/models/__init__.py +43 -0
  222. omnibase_infra/idempotency/models/model_idempotency_check_result.py +85 -0
  223. omnibase_infra/idempotency/models/model_idempotency_guard_config.py +130 -0
  224. omnibase_infra/idempotency/models/model_idempotency_record.py +86 -0
  225. omnibase_infra/idempotency/models/model_idempotency_store_health_check_result.py +81 -0
  226. omnibase_infra/idempotency/models/model_idempotency_store_metrics.py +140 -0
  227. omnibase_infra/idempotency/models/model_postgres_idempotency_store_config.py +299 -0
  228. omnibase_infra/idempotency/protocol_idempotency_store.py +184 -0
  229. omnibase_infra/idempotency/store_inmemory.py +265 -0
  230. omnibase_infra/idempotency/store_postgres.py +923 -0
  231. omnibase_infra/infrastructure/__init__.py +0 -0
  232. omnibase_infra/migrations/001_create_event_ledger.sql +166 -0
  233. omnibase_infra/migrations/001_drop_event_ledger.sql +18 -0
  234. omnibase_infra/mixins/__init__.py +71 -0
  235. omnibase_infra/mixins/mixin_async_circuit_breaker.py +656 -0
  236. omnibase_infra/mixins/mixin_dict_like_accessors.py +146 -0
  237. omnibase_infra/mixins/mixin_envelope_extraction.py +119 -0
  238. omnibase_infra/mixins/mixin_node_introspection.py +2670 -0
  239. omnibase_infra/mixins/mixin_retry_execution.py +386 -0
  240. omnibase_infra/mixins/protocol_circuit_breaker_aware.py +133 -0
  241. omnibase_infra/models/__init__.py +144 -0
  242. omnibase_infra/models/bindings/__init__.py +59 -0
  243. omnibase_infra/models/bindings/constants.py +144 -0
  244. omnibase_infra/models/bindings/model_binding_resolution_result.py +103 -0
  245. omnibase_infra/models/bindings/model_operation_binding.py +44 -0
  246. omnibase_infra/models/bindings/model_operation_bindings_subcontract.py +152 -0
  247. omnibase_infra/models/bindings/model_parsed_binding.py +52 -0
  248. omnibase_infra/models/corpus/__init__.py +17 -0
  249. omnibase_infra/models/corpus/model_capture_config.py +133 -0
  250. omnibase_infra/models/corpus/model_capture_result.py +86 -0
  251. omnibase_infra/models/discovery/__init__.py +42 -0
  252. omnibase_infra/models/discovery/model_dependency_spec.py +319 -0
  253. omnibase_infra/models/discovery/model_discovered_capabilities.py +50 -0
  254. omnibase_infra/models/discovery/model_introspection_config.py +330 -0
  255. omnibase_infra/models/discovery/model_introspection_performance_metrics.py +169 -0
  256. omnibase_infra/models/discovery/model_introspection_task_config.py +116 -0
  257. omnibase_infra/models/dispatch/__init__.py +155 -0
  258. omnibase_infra/models/dispatch/model_debug_trace_snapshot.py +114 -0
  259. omnibase_infra/models/dispatch/model_dispatch_context.py +439 -0
  260. omnibase_infra/models/dispatch/model_dispatch_error.py +336 -0
  261. omnibase_infra/models/dispatch/model_dispatch_log_context.py +400 -0
  262. omnibase_infra/models/dispatch/model_dispatch_metadata.py +228 -0
  263. omnibase_infra/models/dispatch/model_dispatch_metrics.py +496 -0
  264. omnibase_infra/models/dispatch/model_dispatch_outcome.py +317 -0
  265. omnibase_infra/models/dispatch/model_dispatch_outputs.py +231 -0
  266. omnibase_infra/models/dispatch/model_dispatch_result.py +436 -0
  267. omnibase_infra/models/dispatch/model_dispatch_route.py +279 -0
  268. omnibase_infra/models/dispatch/model_dispatcher_metrics.py +275 -0
  269. omnibase_infra/models/dispatch/model_dispatcher_registration.py +352 -0
  270. omnibase_infra/models/dispatch/model_materialized_dispatch.py +141 -0
  271. omnibase_infra/models/dispatch/model_parsed_topic.py +135 -0
  272. omnibase_infra/models/dispatch/model_topic_parser.py +725 -0
  273. omnibase_infra/models/dispatch/model_tracing_context.py +285 -0
  274. omnibase_infra/models/errors/__init__.py +45 -0
  275. omnibase_infra/models/errors/model_handler_validation_error.py +594 -0
  276. omnibase_infra/models/errors/model_infra_error_context.py +99 -0
  277. omnibase_infra/models/errors/model_message_type_registry_error_context.py +71 -0
  278. omnibase_infra/models/errors/model_timeout_error_context.py +110 -0
  279. omnibase_infra/models/handlers/__init__.py +80 -0
  280. omnibase_infra/models/handlers/model_bootstrap_handler_descriptor.py +162 -0
  281. omnibase_infra/models/handlers/model_contract_discovery_result.py +82 -0
  282. omnibase_infra/models/handlers/model_handler_descriptor.py +200 -0
  283. omnibase_infra/models/handlers/model_handler_identifier.py +215 -0
  284. omnibase_infra/models/handlers/model_handler_source_config.py +220 -0
  285. omnibase_infra/models/health/__init__.py +9 -0
  286. omnibase_infra/models/health/model_health_check_result.py +40 -0
  287. omnibase_infra/models/lifecycle/__init__.py +39 -0
  288. omnibase_infra/models/logging/__init__.py +51 -0
  289. omnibase_infra/models/logging/model_log_context.py +756 -0
  290. omnibase_infra/models/mcp/__init__.py +15 -0
  291. omnibase_infra/models/mcp/model_mcp_contract_config.py +80 -0
  292. omnibase_infra/models/mcp/model_mcp_server_config.py +67 -0
  293. omnibase_infra/models/mcp/model_mcp_tool_definition.py +73 -0
  294. omnibase_infra/models/mcp/model_mcp_tool_parameter.py +35 -0
  295. omnibase_infra/models/model_node_identity.py +126 -0
  296. omnibase_infra/models/model_retry_error_classification.py +78 -0
  297. omnibase_infra/models/projection/__init__.py +43 -0
  298. omnibase_infra/models/projection/model_capability_fields.py +112 -0
  299. omnibase_infra/models/projection/model_registration_projection.py +434 -0
  300. omnibase_infra/models/projection/model_registration_snapshot.py +322 -0
  301. omnibase_infra/models/projection/model_sequence_info.py +182 -0
  302. omnibase_infra/models/projection/model_snapshot_topic_config.py +591 -0
  303. omnibase_infra/models/projectors/__init__.py +41 -0
  304. omnibase_infra/models/projectors/model_projector_column.py +289 -0
  305. omnibase_infra/models/projectors/model_projector_discovery_result.py +65 -0
  306. omnibase_infra/models/projectors/model_projector_index.py +270 -0
  307. omnibase_infra/models/projectors/model_projector_schema.py +415 -0
  308. omnibase_infra/models/projectors/model_projector_validation_error.py +63 -0
  309. omnibase_infra/models/projectors/util_sql_identifiers.py +115 -0
  310. omnibase_infra/models/registration/__init__.py +68 -0
  311. omnibase_infra/models/registration/commands/__init__.py +15 -0
  312. omnibase_infra/models/registration/commands/model_node_registration_acked.py +108 -0
  313. omnibase_infra/models/registration/events/__init__.py +56 -0
  314. omnibase_infra/models/registration/events/model_node_became_active.py +103 -0
  315. omnibase_infra/models/registration/events/model_node_liveness_expired.py +103 -0
  316. omnibase_infra/models/registration/events/model_node_registration_accepted.py +98 -0
  317. omnibase_infra/models/registration/events/model_node_registration_ack_received.py +98 -0
  318. omnibase_infra/models/registration/events/model_node_registration_ack_timed_out.py +112 -0
  319. omnibase_infra/models/registration/events/model_node_registration_initiated.py +107 -0
  320. omnibase_infra/models/registration/events/model_node_registration_rejected.py +104 -0
  321. omnibase_infra/models/registration/model_event_bus_topic_entry.py +59 -0
  322. omnibase_infra/models/registration/model_introspection_metrics.py +253 -0
  323. omnibase_infra/models/registration/model_node_capabilities.py +190 -0
  324. omnibase_infra/models/registration/model_node_event_bus_config.py +99 -0
  325. omnibase_infra/models/registration/model_node_heartbeat_event.py +126 -0
  326. omnibase_infra/models/registration/model_node_introspection_event.py +195 -0
  327. omnibase_infra/models/registration/model_node_metadata.py +79 -0
  328. omnibase_infra/models/registration/model_node_registration.py +162 -0
  329. omnibase_infra/models/registration/model_node_registration_record.py +162 -0
  330. omnibase_infra/models/registry/__init__.py +29 -0
  331. omnibase_infra/models/registry/model_domain_constraint.py +202 -0
  332. omnibase_infra/models/registry/model_message_type_entry.py +271 -0
  333. omnibase_infra/models/resilience/__init__.py +9 -0
  334. omnibase_infra/models/resilience/model_circuit_breaker_config.py +227 -0
  335. omnibase_infra/models/routing/__init__.py +25 -0
  336. omnibase_infra/models/routing/model_routing_entry.py +52 -0
  337. omnibase_infra/models/routing/model_routing_subcontract.py +70 -0
  338. omnibase_infra/models/runtime/__init__.py +49 -0
  339. omnibase_infra/models/runtime/model_contract_security_config.py +41 -0
  340. omnibase_infra/models/runtime/model_discovery_error.py +81 -0
  341. omnibase_infra/models/runtime/model_discovery_result.py +162 -0
  342. omnibase_infra/models/runtime/model_discovery_warning.py +74 -0
  343. omnibase_infra/models/runtime/model_failed_plugin_load.py +63 -0
  344. omnibase_infra/models/runtime/model_handler_contract.py +296 -0
  345. omnibase_infra/models/runtime/model_loaded_handler.py +129 -0
  346. omnibase_infra/models/runtime/model_plugin_load_context.py +93 -0
  347. omnibase_infra/models/runtime/model_plugin_load_summary.py +124 -0
  348. omnibase_infra/models/security/__init__.py +50 -0
  349. omnibase_infra/models/security/classification_levels.py +99 -0
  350. omnibase_infra/models/security/model_environment_policy.py +145 -0
  351. omnibase_infra/models/security/model_handler_security_policy.py +107 -0
  352. omnibase_infra/models/security/model_security_error.py +81 -0
  353. omnibase_infra/models/security/model_security_validation_result.py +328 -0
  354. omnibase_infra/models/security/model_security_warning.py +67 -0
  355. omnibase_infra/models/snapshot/__init__.py +27 -0
  356. omnibase_infra/models/snapshot/model_field_change.py +65 -0
  357. omnibase_infra/models/snapshot/model_snapshot.py +270 -0
  358. omnibase_infra/models/snapshot/model_snapshot_diff.py +203 -0
  359. omnibase_infra/models/snapshot/model_subject_ref.py +81 -0
  360. omnibase_infra/models/types/__init__.py +71 -0
  361. omnibase_infra/models/validation/__init__.py +89 -0
  362. omnibase_infra/models/validation/model_any_type_validation_result.py +118 -0
  363. omnibase_infra/models/validation/model_any_type_violation.py +141 -0
  364. omnibase_infra/models/validation/model_category_match_result.py +345 -0
  365. omnibase_infra/models/validation/model_chain_violation.py +166 -0
  366. omnibase_infra/models/validation/model_coverage_metrics.py +316 -0
  367. omnibase_infra/models/validation/model_execution_shape_rule.py +159 -0
  368. omnibase_infra/models/validation/model_execution_shape_validation.py +208 -0
  369. omnibase_infra/models/validation/model_execution_shape_validation_result.py +294 -0
  370. omnibase_infra/models/validation/model_execution_shape_violation.py +122 -0
  371. omnibase_infra/models/validation/model_localhandler_validation_result.py +139 -0
  372. omnibase_infra/models/validation/model_localhandler_violation.py +100 -0
  373. omnibase_infra/models/validation/model_output_validation_params.py +74 -0
  374. omnibase_infra/models/validation/model_validate_and_raise_params.py +84 -0
  375. omnibase_infra/models/validation/model_validation_error_params.py +84 -0
  376. omnibase_infra/models/validation/model_validation_outcome.py +287 -0
  377. omnibase_infra/nodes/__init__.py +57 -0
  378. omnibase_infra/nodes/architecture_validator/__init__.py +79 -0
  379. omnibase_infra/nodes/architecture_validator/contract.yaml +252 -0
  380. omnibase_infra/nodes/architecture_validator/contract_architecture_validator.yaml +203 -0
  381. omnibase_infra/nodes/architecture_validator/mixins/__init__.py +16 -0
  382. omnibase_infra/nodes/architecture_validator/mixins/mixin_file_path_rule.py +92 -0
  383. omnibase_infra/nodes/architecture_validator/models/__init__.py +36 -0
  384. omnibase_infra/nodes/architecture_validator/models/model_architecture_validation_request.py +56 -0
  385. omnibase_infra/nodes/architecture_validator/models/model_architecture_validation_result.py +311 -0
  386. omnibase_infra/nodes/architecture_validator/models/model_architecture_violation.py +163 -0
  387. omnibase_infra/nodes/architecture_validator/models/model_rule_check_result.py +265 -0
  388. omnibase_infra/nodes/architecture_validator/models/model_validation_request.py +105 -0
  389. omnibase_infra/nodes/architecture_validator/models/model_validation_result.py +314 -0
  390. omnibase_infra/nodes/architecture_validator/node.py +262 -0
  391. omnibase_infra/nodes/architecture_validator/node_architecture_validator.py +383 -0
  392. omnibase_infra/nodes/architecture_validator/protocols/__init__.py +9 -0
  393. omnibase_infra/nodes/architecture_validator/protocols/protocol_architecture_rule.py +225 -0
  394. omnibase_infra/nodes/architecture_validator/registry/__init__.py +28 -0
  395. omnibase_infra/nodes/architecture_validator/registry/registry_infra_architecture_validator.py +106 -0
  396. omnibase_infra/nodes/architecture_validator/validators/__init__.py +104 -0
  397. omnibase_infra/nodes/architecture_validator/validators/validator_no_direct_dispatch.py +422 -0
  398. omnibase_infra/nodes/architecture_validator/validators/validator_no_handler_publishing.py +481 -0
  399. omnibase_infra/nodes/architecture_validator/validators/validator_no_orchestrator_fsm.py +491 -0
  400. omnibase_infra/nodes/contract_registry_reducer/__init__.py +29 -0
  401. omnibase_infra/nodes/contract_registry_reducer/contract.yaml +255 -0
  402. omnibase_infra/nodes/contract_registry_reducer/models/__init__.py +38 -0
  403. omnibase_infra/nodes/contract_registry_reducer/models/model_contract_registry_state.py +266 -0
  404. omnibase_infra/nodes/contract_registry_reducer/models/model_payload_cleanup_topic_references.py +55 -0
  405. omnibase_infra/nodes/contract_registry_reducer/models/model_payload_deactivate_contract.py +58 -0
  406. omnibase_infra/nodes/contract_registry_reducer/models/model_payload_mark_stale.py +49 -0
  407. omnibase_infra/nodes/contract_registry_reducer/models/model_payload_update_heartbeat.py +71 -0
  408. omnibase_infra/nodes/contract_registry_reducer/models/model_payload_update_topic.py +66 -0
  409. omnibase_infra/nodes/contract_registry_reducer/models/model_payload_upsert_contract.py +92 -0
  410. omnibase_infra/nodes/contract_registry_reducer/node.py +121 -0
  411. omnibase_infra/nodes/contract_registry_reducer/reducer.py +784 -0
  412. omnibase_infra/nodes/contract_registry_reducer/registry/__init__.py +9 -0
  413. omnibase_infra/nodes/contract_registry_reducer/registry/registry_infra_contract_registry_reducer.py +101 -0
  414. omnibase_infra/nodes/effects/README.md +358 -0
  415. omnibase_infra/nodes/effects/__init__.py +26 -0
  416. omnibase_infra/nodes/effects/contract.yaml +167 -0
  417. omnibase_infra/nodes/effects/models/__init__.py +32 -0
  418. omnibase_infra/nodes/effects/models/model_backend_result.py +190 -0
  419. omnibase_infra/nodes/effects/models/model_effect_idempotency_config.py +92 -0
  420. omnibase_infra/nodes/effects/models/model_registry_request.py +132 -0
  421. omnibase_infra/nodes/effects/models/model_registry_response.py +263 -0
  422. omnibase_infra/nodes/effects/protocol_consul_client.py +89 -0
  423. omnibase_infra/nodes/effects/protocol_effect_idempotency_store.py +143 -0
  424. omnibase_infra/nodes/effects/protocol_postgres_adapter.py +96 -0
  425. omnibase_infra/nodes/effects/registry_effect.py +525 -0
  426. omnibase_infra/nodes/effects/store_effect_idempotency_inmemory.py +425 -0
  427. omnibase_infra/nodes/handlers/consul/contract.yaml +85 -0
  428. omnibase_infra/nodes/handlers/db/contract.yaml +72 -0
  429. omnibase_infra/nodes/handlers/graph/contract.yaml +127 -0
  430. omnibase_infra/nodes/handlers/http/contract.yaml +74 -0
  431. omnibase_infra/nodes/handlers/intent/contract.yaml +66 -0
  432. omnibase_infra/nodes/handlers/mcp/contract.yaml +69 -0
  433. omnibase_infra/nodes/handlers/vault/contract.yaml +91 -0
  434. omnibase_infra/nodes/node_intent_storage_effect/__init__.py +50 -0
  435. omnibase_infra/nodes/node_intent_storage_effect/contract.yaml +194 -0
  436. omnibase_infra/nodes/node_intent_storage_effect/models/__init__.py +24 -0
  437. omnibase_infra/nodes/node_intent_storage_effect/models/model_intent_storage_input.py +141 -0
  438. omnibase_infra/nodes/node_intent_storage_effect/models/model_intent_storage_output.py +130 -0
  439. omnibase_infra/nodes/node_intent_storage_effect/node.py +94 -0
  440. omnibase_infra/nodes/node_intent_storage_effect/registry/__init__.py +35 -0
  441. omnibase_infra/nodes/node_intent_storage_effect/registry/registry_infra_intent_storage.py +294 -0
  442. omnibase_infra/nodes/node_ledger_projection_compute/__init__.py +50 -0
  443. omnibase_infra/nodes/node_ledger_projection_compute/contract.yaml +104 -0
  444. omnibase_infra/nodes/node_ledger_projection_compute/node.py +284 -0
  445. omnibase_infra/nodes/node_ledger_projection_compute/registry/__init__.py +29 -0
  446. omnibase_infra/nodes/node_ledger_projection_compute/registry/registry_infra_ledger_projection.py +118 -0
  447. omnibase_infra/nodes/node_ledger_write_effect/__init__.py +82 -0
  448. omnibase_infra/nodes/node_ledger_write_effect/contract.yaml +200 -0
  449. omnibase_infra/nodes/node_ledger_write_effect/handlers/__init__.py +22 -0
  450. omnibase_infra/nodes/node_ledger_write_effect/handlers/handler_ledger_append.py +372 -0
  451. omnibase_infra/nodes/node_ledger_write_effect/handlers/handler_ledger_query.py +597 -0
  452. omnibase_infra/nodes/node_ledger_write_effect/models/__init__.py +31 -0
  453. omnibase_infra/nodes/node_ledger_write_effect/models/model_ledger_append_result.py +54 -0
  454. omnibase_infra/nodes/node_ledger_write_effect/models/model_ledger_entry.py +92 -0
  455. omnibase_infra/nodes/node_ledger_write_effect/models/model_ledger_query.py +53 -0
  456. omnibase_infra/nodes/node_ledger_write_effect/models/model_ledger_query_result.py +41 -0
  457. omnibase_infra/nodes/node_ledger_write_effect/node.py +89 -0
  458. omnibase_infra/nodes/node_ledger_write_effect/protocols/__init__.py +13 -0
  459. omnibase_infra/nodes/node_ledger_write_effect/protocols/protocol_ledger_persistence.py +127 -0
  460. omnibase_infra/nodes/node_ledger_write_effect/registry/__init__.py +9 -0
  461. omnibase_infra/nodes/node_ledger_write_effect/registry/registry_infra_ledger_write.py +121 -0
  462. omnibase_infra/nodes/node_registration_orchestrator/README.md +542 -0
  463. omnibase_infra/nodes/node_registration_orchestrator/__init__.py +120 -0
  464. omnibase_infra/nodes/node_registration_orchestrator/contract.yaml +482 -0
  465. omnibase_infra/nodes/node_registration_orchestrator/dispatchers/__init__.py +53 -0
  466. omnibase_infra/nodes/node_registration_orchestrator/dispatchers/dispatcher_node_introspected.py +376 -0
  467. omnibase_infra/nodes/node_registration_orchestrator/dispatchers/dispatcher_node_registration_acked.py +376 -0
  468. omnibase_infra/nodes/node_registration_orchestrator/dispatchers/dispatcher_runtime_tick.py +373 -0
  469. omnibase_infra/nodes/node_registration_orchestrator/handlers/__init__.py +62 -0
  470. omnibase_infra/nodes/node_registration_orchestrator/handlers/handler_node_heartbeat.py +376 -0
  471. omnibase_infra/nodes/node_registration_orchestrator/handlers/handler_node_introspected.py +694 -0
  472. omnibase_infra/nodes/node_registration_orchestrator/handlers/handler_node_registration_acked.py +458 -0
  473. omnibase_infra/nodes/node_registration_orchestrator/handlers/handler_runtime_tick.py +364 -0
  474. omnibase_infra/nodes/node_registration_orchestrator/introspection_event_router.py +544 -0
  475. omnibase_infra/nodes/node_registration_orchestrator/models/__init__.py +75 -0
  476. omnibase_infra/nodes/node_registration_orchestrator/models/model_consul_intent_payload.py +194 -0
  477. omnibase_infra/nodes/node_registration_orchestrator/models/model_consul_registration_intent.py +67 -0
  478. omnibase_infra/nodes/node_registration_orchestrator/models/model_intent_execution_result.py +50 -0
  479. omnibase_infra/nodes/node_registration_orchestrator/models/model_node_liveness_expired.py +107 -0
  480. omnibase_infra/nodes/node_registration_orchestrator/models/model_orchestrator_config.py +67 -0
  481. omnibase_infra/nodes/node_registration_orchestrator/models/model_orchestrator_input.py +41 -0
  482. omnibase_infra/nodes/node_registration_orchestrator/models/model_orchestrator_output.py +166 -0
  483. omnibase_infra/nodes/node_registration_orchestrator/models/model_postgres_intent_payload.py +235 -0
  484. omnibase_infra/nodes/node_registration_orchestrator/models/model_postgres_upsert_intent.py +68 -0
  485. omnibase_infra/nodes/node_registration_orchestrator/models/model_reducer_execution_result.py +384 -0
  486. omnibase_infra/nodes/node_registration_orchestrator/models/model_reducer_state.py +60 -0
  487. omnibase_infra/nodes/node_registration_orchestrator/models/model_registration_intent.py +177 -0
  488. omnibase_infra/nodes/node_registration_orchestrator/models/model_registry_intent.py +247 -0
  489. omnibase_infra/nodes/node_registration_orchestrator/node.py +195 -0
  490. omnibase_infra/nodes/node_registration_orchestrator/plugin.py +909 -0
  491. omnibase_infra/nodes/node_registration_orchestrator/protocols.py +439 -0
  492. omnibase_infra/nodes/node_registration_orchestrator/registry/__init__.py +41 -0
  493. omnibase_infra/nodes/node_registration_orchestrator/registry/registry_infra_node_registration_orchestrator.py +528 -0
  494. omnibase_infra/nodes/node_registration_orchestrator/timeout_coordinator.py +393 -0
  495. omnibase_infra/nodes/node_registration_orchestrator/wiring.py +743 -0
  496. omnibase_infra/nodes/node_registration_reducer/__init__.py +15 -0
  497. omnibase_infra/nodes/node_registration_reducer/contract.yaml +301 -0
  498. omnibase_infra/nodes/node_registration_reducer/models/__init__.py +38 -0
  499. omnibase_infra/nodes/node_registration_reducer/models/model_validation_result.py +113 -0
  500. omnibase_infra/nodes/node_registration_reducer/node.py +139 -0
  501. omnibase_infra/nodes/node_registration_reducer/registry/__init__.py +9 -0
  502. omnibase_infra/nodes/node_registration_reducer/registry/registry_infra_node_registration_reducer.py +79 -0
  503. omnibase_infra/nodes/node_registration_storage_effect/__init__.py +41 -0
  504. omnibase_infra/nodes/node_registration_storage_effect/contract.yaml +220 -0
  505. omnibase_infra/nodes/node_registration_storage_effect/models/__init__.py +44 -0
  506. omnibase_infra/nodes/node_registration_storage_effect/models/model_delete_result.py +132 -0
  507. omnibase_infra/nodes/node_registration_storage_effect/models/model_registration_record.py +199 -0
  508. omnibase_infra/nodes/node_registration_storage_effect/models/model_registration_update.py +155 -0
  509. omnibase_infra/nodes/node_registration_storage_effect/models/model_storage_health_check_details.py +123 -0
  510. omnibase_infra/nodes/node_registration_storage_effect/models/model_storage_health_check_result.py +117 -0
  511. omnibase_infra/nodes/node_registration_storage_effect/models/model_storage_query.py +100 -0
  512. omnibase_infra/nodes/node_registration_storage_effect/models/model_storage_result.py +136 -0
  513. omnibase_infra/nodes/node_registration_storage_effect/models/model_upsert_result.py +127 -0
  514. omnibase_infra/nodes/node_registration_storage_effect/node.py +112 -0
  515. omnibase_infra/nodes/node_registration_storage_effect/protocols/__init__.py +22 -0
  516. omnibase_infra/nodes/node_registration_storage_effect/protocols/protocol_registration_persistence.py +333 -0
  517. omnibase_infra/nodes/node_registration_storage_effect/registry/__init__.py +23 -0
  518. omnibase_infra/nodes/node_registration_storage_effect/registry/registry_infra_registration_storage.py +215 -0
  519. omnibase_infra/nodes/node_registry_effect/__init__.py +85 -0
  520. omnibase_infra/nodes/node_registry_effect/contract.yaml +677 -0
  521. omnibase_infra/nodes/node_registry_effect/handlers/__init__.py +70 -0
  522. omnibase_infra/nodes/node_registry_effect/handlers/handler_consul_deregister.py +211 -0
  523. omnibase_infra/nodes/node_registry_effect/handlers/handler_consul_register.py +212 -0
  524. omnibase_infra/nodes/node_registry_effect/handlers/handler_partial_retry.py +417 -0
  525. omnibase_infra/nodes/node_registry_effect/handlers/handler_postgres_deactivate.py +215 -0
  526. omnibase_infra/nodes/node_registry_effect/handlers/handler_postgres_upsert.py +208 -0
  527. omnibase_infra/nodes/node_registry_effect/models/__init__.py +43 -0
  528. omnibase_infra/nodes/node_registry_effect/models/model_partial_retry_request.py +92 -0
  529. omnibase_infra/nodes/node_registry_effect/node.py +165 -0
  530. omnibase_infra/nodes/node_registry_effect/registry/__init__.py +27 -0
  531. omnibase_infra/nodes/node_registry_effect/registry/registry_infra_registry_effect.py +196 -0
  532. omnibase_infra/nodes/node_service_discovery_effect/__init__.py +111 -0
  533. omnibase_infra/nodes/node_service_discovery_effect/contract.yaml +246 -0
  534. omnibase_infra/nodes/node_service_discovery_effect/models/__init__.py +67 -0
  535. omnibase_infra/nodes/node_service_discovery_effect/models/enum_health_status.py +72 -0
  536. omnibase_infra/nodes/node_service_discovery_effect/models/enum_service_discovery_operation.py +58 -0
  537. omnibase_infra/nodes/node_service_discovery_effect/models/model_discovery_query.py +99 -0
  538. omnibase_infra/nodes/node_service_discovery_effect/models/model_discovery_result.py +98 -0
  539. omnibase_infra/nodes/node_service_discovery_effect/models/model_health_check_config.py +121 -0
  540. omnibase_infra/nodes/node_service_discovery_effect/models/model_query_metadata.py +63 -0
  541. omnibase_infra/nodes/node_service_discovery_effect/models/model_registration_result.py +130 -0
  542. omnibase_infra/nodes/node_service_discovery_effect/models/model_service_discovery_health_check_details.py +111 -0
  543. omnibase_infra/nodes/node_service_discovery_effect/models/model_service_discovery_health_check_result.py +119 -0
  544. omnibase_infra/nodes/node_service_discovery_effect/models/model_service_info.py +106 -0
  545. omnibase_infra/nodes/node_service_discovery_effect/models/model_service_registration.py +121 -0
  546. omnibase_infra/nodes/node_service_discovery_effect/node.py +111 -0
  547. omnibase_infra/nodes/node_service_discovery_effect/protocols/__init__.py +14 -0
  548. omnibase_infra/nodes/node_service_discovery_effect/protocols/protocol_discovery_operations.py +279 -0
  549. omnibase_infra/nodes/node_service_discovery_effect/registry/__init__.py +13 -0
  550. omnibase_infra/nodes/node_service_discovery_effect/registry/registry_infra_service_discovery.py +222 -0
  551. omnibase_infra/nodes/reducers/__init__.py +30 -0
  552. omnibase_infra/nodes/reducers/models/__init__.py +37 -0
  553. omnibase_infra/nodes/reducers/models/model_payload_consul_register.py +87 -0
  554. omnibase_infra/nodes/reducers/models/model_payload_ledger_append.py +133 -0
  555. omnibase_infra/nodes/reducers/models/model_payload_postgres_upsert_registration.py +60 -0
  556. omnibase_infra/nodes/reducers/models/model_registration_confirmation.py +166 -0
  557. omnibase_infra/nodes/reducers/models/model_registration_state.py +433 -0
  558. omnibase_infra/nodes/reducers/registration_reducer.py +1138 -0
  559. omnibase_infra/observability/__init__.py +143 -0
  560. omnibase_infra/observability/constants_metrics.py +91 -0
  561. omnibase_infra/observability/factory_observability_sink.py +525 -0
  562. omnibase_infra/observability/handlers/__init__.py +118 -0
  563. omnibase_infra/observability/handlers/handler_logging_structured.py +967 -0
  564. omnibase_infra/observability/handlers/handler_metrics_prometheus.py +1120 -0
  565. omnibase_infra/observability/handlers/model_logging_handler_config.py +71 -0
  566. omnibase_infra/observability/handlers/model_logging_handler_response.py +77 -0
  567. omnibase_infra/observability/handlers/model_metrics_handler_config.py +172 -0
  568. omnibase_infra/observability/handlers/model_metrics_handler_payload.py +135 -0
  569. omnibase_infra/observability/handlers/model_metrics_handler_response.py +101 -0
  570. omnibase_infra/observability/hooks/__init__.py +74 -0
  571. omnibase_infra/observability/hooks/hook_observability.py +1223 -0
  572. omnibase_infra/observability/models/__init__.py +30 -0
  573. omnibase_infra/observability/models/enum_required_log_context_key.py +77 -0
  574. omnibase_infra/observability/models/model_buffered_log_entry.py +117 -0
  575. omnibase_infra/observability/models/model_logging_sink_config.py +73 -0
  576. omnibase_infra/observability/models/model_metrics_sink_config.py +156 -0
  577. omnibase_infra/observability/sinks/__init__.py +69 -0
  578. omnibase_infra/observability/sinks/sink_logging_structured.py +809 -0
  579. omnibase_infra/observability/sinks/sink_metrics_prometheus.py +710 -0
  580. omnibase_infra/plugins/__init__.py +27 -0
  581. omnibase_infra/plugins/examples/__init__.py +28 -0
  582. omnibase_infra/plugins/examples/plugin_json_normalizer.py +271 -0
  583. omnibase_infra/plugins/examples/plugin_json_normalizer_error_handling.py +210 -0
  584. omnibase_infra/plugins/models/__init__.py +21 -0
  585. omnibase_infra/plugins/models/model_plugin_context.py +76 -0
  586. omnibase_infra/plugins/models/model_plugin_input_data.py +58 -0
  587. omnibase_infra/plugins/models/model_plugin_output_data.py +62 -0
  588. omnibase_infra/plugins/plugin_compute_base.py +449 -0
  589. omnibase_infra/projectors/__init__.py +30 -0
  590. omnibase_infra/projectors/contracts/__init__.py +63 -0
  591. omnibase_infra/projectors/contracts/registration_projector.yaml +370 -0
  592. omnibase_infra/projectors/projection_reader_registration.py +1559 -0
  593. omnibase_infra/projectors/snapshot_publisher_registration.py +1329 -0
  594. omnibase_infra/protocols/__init__.py +104 -0
  595. omnibase_infra/protocols/protocol_capability_projection.py +253 -0
  596. omnibase_infra/protocols/protocol_capability_query.py +251 -0
  597. omnibase_infra/protocols/protocol_container_aware.py +200 -0
  598. omnibase_infra/protocols/protocol_dispatch_engine.py +152 -0
  599. omnibase_infra/protocols/protocol_event_bus_like.py +127 -0
  600. omnibase_infra/protocols/protocol_event_projector.py +96 -0
  601. omnibase_infra/protocols/protocol_idempotency_store.py +142 -0
  602. omnibase_infra/protocols/protocol_message_dispatcher.py +247 -0
  603. omnibase_infra/protocols/protocol_message_type_registry.py +306 -0
  604. omnibase_infra/protocols/protocol_plugin_compute.py +368 -0
  605. omnibase_infra/protocols/protocol_projector_schema_validator.py +82 -0
  606. omnibase_infra/protocols/protocol_registry_metrics.py +215 -0
  607. omnibase_infra/protocols/protocol_snapshot_publisher.py +396 -0
  608. omnibase_infra/protocols/protocol_snapshot_store.py +567 -0
  609. omnibase_infra/runtime/__init__.py +445 -0
  610. omnibase_infra/runtime/binding_config_resolver.py +2771 -0
  611. omnibase_infra/runtime/binding_resolver.py +753 -0
  612. omnibase_infra/runtime/chain_aware_dispatch.py +467 -0
  613. omnibase_infra/runtime/constants_notification.py +75 -0
  614. omnibase_infra/runtime/constants_security.py +70 -0
  615. omnibase_infra/runtime/contract_handler_discovery.py +587 -0
  616. omnibase_infra/runtime/contract_loaders/__init__.py +51 -0
  617. omnibase_infra/runtime/contract_loaders/handler_routing_loader.py +464 -0
  618. omnibase_infra/runtime/contract_loaders/operation_bindings_loader.py +789 -0
  619. omnibase_infra/runtime/dispatch_context_enforcer.py +427 -0
  620. omnibase_infra/runtime/emit_daemon/__init__.py +97 -0
  621. omnibase_infra/runtime/emit_daemon/cli.py +844 -0
  622. omnibase_infra/runtime/emit_daemon/client.py +811 -0
  623. omnibase_infra/runtime/emit_daemon/config.py +535 -0
  624. omnibase_infra/runtime/emit_daemon/daemon.py +812 -0
  625. omnibase_infra/runtime/emit_daemon/event_registry.py +477 -0
  626. omnibase_infra/runtime/emit_daemon/model_daemon_request.py +139 -0
  627. omnibase_infra/runtime/emit_daemon/model_daemon_response.py +191 -0
  628. omnibase_infra/runtime/emit_daemon/queue.py +618 -0
  629. omnibase_infra/runtime/enums/__init__.py +18 -0
  630. omnibase_infra/runtime/enums/enum_config_ref_scheme.py +33 -0
  631. omnibase_infra/runtime/enums/enum_scheduler_status.py +170 -0
  632. omnibase_infra/runtime/envelope_validator.py +179 -0
  633. omnibase_infra/runtime/event_bus_subcontract_wiring.py +466 -0
  634. omnibase_infra/runtime/handler_bootstrap_source.py +507 -0
  635. omnibase_infra/runtime/handler_contract_config_loader.py +603 -0
  636. omnibase_infra/runtime/handler_contract_source.py +750 -0
  637. omnibase_infra/runtime/handler_identity.py +81 -0
  638. omnibase_infra/runtime/handler_plugin_loader.py +2046 -0
  639. omnibase_infra/runtime/handler_registry.py +329 -0
  640. omnibase_infra/runtime/handler_source_resolver.py +367 -0
  641. omnibase_infra/runtime/invocation_security_enforcer.py +427 -0
  642. omnibase_infra/runtime/kafka_contract_source.py +984 -0
  643. omnibase_infra/runtime/kernel.py +40 -0
  644. omnibase_infra/runtime/mixin_policy_validation.py +522 -0
  645. omnibase_infra/runtime/mixin_semver_cache.py +402 -0
  646. omnibase_infra/runtime/mixins/__init__.py +24 -0
  647. omnibase_infra/runtime/mixins/mixin_projector_notification_publishing.py +566 -0
  648. omnibase_infra/runtime/mixins/mixin_projector_sql_operations.py +778 -0
  649. omnibase_infra/runtime/models/__init__.py +229 -0
  650. omnibase_infra/runtime/models/model_batch_lifecycle_result.py +217 -0
  651. omnibase_infra/runtime/models/model_binding_config.py +168 -0
  652. omnibase_infra/runtime/models/model_binding_config_cache_stats.py +135 -0
  653. omnibase_infra/runtime/models/model_binding_config_resolver_config.py +329 -0
  654. omnibase_infra/runtime/models/model_cached_secret.py +138 -0
  655. omnibase_infra/runtime/models/model_compute_key.py +138 -0
  656. omnibase_infra/runtime/models/model_compute_registration.py +97 -0
  657. omnibase_infra/runtime/models/model_config_cache_entry.py +61 -0
  658. omnibase_infra/runtime/models/model_config_ref.py +331 -0
  659. omnibase_infra/runtime/models/model_config_ref_parse_result.py +125 -0
  660. omnibase_infra/runtime/models/model_contract_load_result.py +224 -0
  661. omnibase_infra/runtime/models/model_domain_plugin_config.py +92 -0
  662. omnibase_infra/runtime/models/model_domain_plugin_result.py +270 -0
  663. omnibase_infra/runtime/models/model_duplicate_response.py +54 -0
  664. omnibase_infra/runtime/models/model_enabled_protocols_config.py +61 -0
  665. omnibase_infra/runtime/models/model_event_bus_config.py +54 -0
  666. omnibase_infra/runtime/models/model_failed_component.py +55 -0
  667. omnibase_infra/runtime/models/model_health_check_response.py +168 -0
  668. omnibase_infra/runtime/models/model_health_check_result.py +229 -0
  669. omnibase_infra/runtime/models/model_lifecycle_result.py +245 -0
  670. omnibase_infra/runtime/models/model_logging_config.py +42 -0
  671. omnibase_infra/runtime/models/model_optional_correlation_id.py +167 -0
  672. omnibase_infra/runtime/models/model_optional_string.py +94 -0
  673. omnibase_infra/runtime/models/model_optional_uuid.py +110 -0
  674. omnibase_infra/runtime/models/model_policy_context.py +100 -0
  675. omnibase_infra/runtime/models/model_policy_key.py +138 -0
  676. omnibase_infra/runtime/models/model_policy_registration.py +139 -0
  677. omnibase_infra/runtime/models/model_policy_result.py +103 -0
  678. omnibase_infra/runtime/models/model_policy_type_filter.py +157 -0
  679. omnibase_infra/runtime/models/model_projector_notification_config.py +171 -0
  680. omnibase_infra/runtime/models/model_projector_plugin_loader_config.py +47 -0
  681. omnibase_infra/runtime/models/model_protocol_registration_config.py +65 -0
  682. omnibase_infra/runtime/models/model_retry_policy.py +105 -0
  683. omnibase_infra/runtime/models/model_runtime_config.py +150 -0
  684. omnibase_infra/runtime/models/model_runtime_contract_config.py +268 -0
  685. omnibase_infra/runtime/models/model_runtime_scheduler_config.py +625 -0
  686. omnibase_infra/runtime/models/model_runtime_scheduler_metrics.py +233 -0
  687. omnibase_infra/runtime/models/model_runtime_tick.py +193 -0
  688. omnibase_infra/runtime/models/model_secret_cache_stats.py +82 -0
  689. omnibase_infra/runtime/models/model_secret_mapping.py +63 -0
  690. omnibase_infra/runtime/models/model_secret_resolver_config.py +107 -0
  691. omnibase_infra/runtime/models/model_secret_resolver_metrics.py +111 -0
  692. omnibase_infra/runtime/models/model_secret_source_info.py +72 -0
  693. omnibase_infra/runtime/models/model_secret_source_spec.py +66 -0
  694. omnibase_infra/runtime/models/model_security_config.py +109 -0
  695. omnibase_infra/runtime/models/model_shutdown_batch_result.py +75 -0
  696. omnibase_infra/runtime/models/model_shutdown_config.py +94 -0
  697. omnibase_infra/runtime/models/model_transition_notification_outbox_config.py +112 -0
  698. omnibase_infra/runtime/models/model_transition_notification_outbox_metrics.py +140 -0
  699. omnibase_infra/runtime/models/model_transition_notification_publisher_metrics.py +357 -0
  700. omnibase_infra/runtime/projector_plugin_loader.py +1462 -0
  701. omnibase_infra/runtime/projector_schema_manager.py +565 -0
  702. omnibase_infra/runtime/projector_shell.py +1330 -0
  703. omnibase_infra/runtime/protocol_contract_descriptor.py +92 -0
  704. omnibase_infra/runtime/protocol_contract_source.py +92 -0
  705. omnibase_infra/runtime/protocol_domain_plugin.py +474 -0
  706. omnibase_infra/runtime/protocol_handler_discovery.py +221 -0
  707. omnibase_infra/runtime/protocol_handler_plugin_loader.py +327 -0
  708. omnibase_infra/runtime/protocol_lifecycle_executor.py +435 -0
  709. omnibase_infra/runtime/protocol_policy.py +366 -0
  710. omnibase_infra/runtime/protocols/__init__.py +37 -0
  711. omnibase_infra/runtime/protocols/protocol_runtime_scheduler.py +468 -0
  712. omnibase_infra/runtime/publisher_topic_scoped.py +294 -0
  713. omnibase_infra/runtime/registry/__init__.py +93 -0
  714. omnibase_infra/runtime/registry/mixin_message_type_query.py +326 -0
  715. omnibase_infra/runtime/registry/mixin_message_type_registration.py +354 -0
  716. omnibase_infra/runtime/registry/registry_event_bus_binding.py +268 -0
  717. omnibase_infra/runtime/registry/registry_message_type.py +542 -0
  718. omnibase_infra/runtime/registry/registry_protocol_binding.py +445 -0
  719. omnibase_infra/runtime/registry_compute.py +1143 -0
  720. omnibase_infra/runtime/registry_contract_source.py +693 -0
  721. omnibase_infra/runtime/registry_dispatcher.py +678 -0
  722. omnibase_infra/runtime/registry_policy.py +1185 -0
  723. omnibase_infra/runtime/runtime_contract_config_loader.py +406 -0
  724. omnibase_infra/runtime/runtime_scheduler.py +1070 -0
  725. omnibase_infra/runtime/secret_resolver.py +2112 -0
  726. omnibase_infra/runtime/security_metadata_validator.py +776 -0
  727. omnibase_infra/runtime/service_kernel.py +1651 -0
  728. omnibase_infra/runtime/service_message_dispatch_engine.py +2350 -0
  729. omnibase_infra/runtime/service_runtime_host_process.py +3493 -0
  730. omnibase_infra/runtime/transition_notification_outbox.py +1190 -0
  731. omnibase_infra/runtime/transition_notification_publisher.py +765 -0
  732. omnibase_infra/runtime/util_container_wiring.py +1124 -0
  733. omnibase_infra/runtime/util_validation.py +314 -0
  734. omnibase_infra/runtime/util_version.py +98 -0
  735. omnibase_infra/runtime/util_wiring.py +723 -0
  736. omnibase_infra/schemas/schema_registration_projection.sql +320 -0
  737. omnibase_infra/schemas/schema_transition_notification_outbox.sql +245 -0
  738. omnibase_infra/services/__init__.py +89 -0
  739. omnibase_infra/services/corpus_capture.py +684 -0
  740. omnibase_infra/services/mcp/__init__.py +31 -0
  741. omnibase_infra/services/mcp/mcp_server_lifecycle.py +449 -0
  742. omnibase_infra/services/mcp/service_mcp_tool_discovery.py +411 -0
  743. omnibase_infra/services/mcp/service_mcp_tool_registry.py +329 -0
  744. omnibase_infra/services/mcp/service_mcp_tool_sync.py +565 -0
  745. omnibase_infra/services/registry_api/__init__.py +40 -0
  746. omnibase_infra/services/registry_api/main.py +261 -0
  747. omnibase_infra/services/registry_api/models/__init__.py +66 -0
  748. omnibase_infra/services/registry_api/models/model_capability_widget_mapping.py +38 -0
  749. omnibase_infra/services/registry_api/models/model_pagination_info.py +48 -0
  750. omnibase_infra/services/registry_api/models/model_registry_discovery_response.py +73 -0
  751. omnibase_infra/services/registry_api/models/model_registry_health_response.py +49 -0
  752. omnibase_infra/services/registry_api/models/model_registry_instance_view.py +88 -0
  753. omnibase_infra/services/registry_api/models/model_registry_node_view.py +88 -0
  754. omnibase_infra/services/registry_api/models/model_registry_summary.py +60 -0
  755. omnibase_infra/services/registry_api/models/model_response_list_instances.py +43 -0
  756. omnibase_infra/services/registry_api/models/model_response_list_nodes.py +51 -0
  757. omnibase_infra/services/registry_api/models/model_warning.py +49 -0
  758. omnibase_infra/services/registry_api/models/model_widget_defaults.py +28 -0
  759. omnibase_infra/services/registry_api/models/model_widget_mapping.py +51 -0
  760. omnibase_infra/services/registry_api/routes.py +371 -0
  761. omnibase_infra/services/registry_api/service.py +837 -0
  762. omnibase_infra/services/service_capability_query.py +945 -0
  763. omnibase_infra/services/service_health.py +898 -0
  764. omnibase_infra/services/service_node_selector.py +530 -0
  765. omnibase_infra/services/service_timeout_emitter.py +699 -0
  766. omnibase_infra/services/service_timeout_scanner.py +394 -0
  767. omnibase_infra/services/session/__init__.py +56 -0
  768. omnibase_infra/services/session/config_consumer.py +137 -0
  769. omnibase_infra/services/session/config_store.py +139 -0
  770. omnibase_infra/services/session/consumer.py +1007 -0
  771. omnibase_infra/services/session/protocol_session_aggregator.py +117 -0
  772. omnibase_infra/services/session/store.py +997 -0
  773. omnibase_infra/services/snapshot/__init__.py +31 -0
  774. omnibase_infra/services/snapshot/service_snapshot.py +647 -0
  775. omnibase_infra/services/snapshot/store_inmemory.py +637 -0
  776. omnibase_infra/services/snapshot/store_postgres.py +1279 -0
  777. omnibase_infra/shared/__init__.py +8 -0
  778. omnibase_infra/testing/__init__.py +10 -0
  779. omnibase_infra/testing/utils.py +23 -0
  780. omnibase_infra/topics/__init__.py +45 -0
  781. omnibase_infra/topics/platform_topic_suffixes.py +140 -0
  782. omnibase_infra/topics/util_topic_composition.py +95 -0
  783. omnibase_infra/types/__init__.py +48 -0
  784. omnibase_infra/types/type_cache_info.py +49 -0
  785. omnibase_infra/types/type_dsn.py +173 -0
  786. omnibase_infra/types/type_infra_aliases.py +60 -0
  787. omnibase_infra/types/typed_dict/__init__.py +29 -0
  788. omnibase_infra/types/typed_dict/typed_dict_envelope_build_params.py +115 -0
  789. omnibase_infra/types/typed_dict/typed_dict_introspection_cache.py +128 -0
  790. omnibase_infra/types/typed_dict/typed_dict_performance_metrics_cache.py +140 -0
  791. omnibase_infra/types/typed_dict_capabilities.py +64 -0
  792. omnibase_infra/utils/__init__.py +117 -0
  793. omnibase_infra/utils/correlation.py +208 -0
  794. omnibase_infra/utils/util_atomic_file.py +261 -0
  795. omnibase_infra/utils/util_consumer_group.py +232 -0
  796. omnibase_infra/utils/util_datetime.py +372 -0
  797. omnibase_infra/utils/util_db_transaction.py +239 -0
  798. omnibase_infra/utils/util_dsn_validation.py +333 -0
  799. omnibase_infra/utils/util_env_parsing.py +264 -0
  800. omnibase_infra/utils/util_error_sanitization.py +457 -0
  801. omnibase_infra/utils/util_pydantic_validators.py +477 -0
  802. omnibase_infra/utils/util_retry_optimistic.py +281 -0
  803. omnibase_infra/utils/util_semver.py +233 -0
  804. omnibase_infra/validation/__init__.py +307 -0
  805. omnibase_infra/validation/contracts/security.validation.yaml +114 -0
  806. omnibase_infra/validation/enums/__init__.py +11 -0
  807. omnibase_infra/validation/enums/enum_contract_violation_severity.py +13 -0
  808. omnibase_infra/validation/infra_validators.py +1514 -0
  809. omnibase_infra/validation/linter_contract.py +907 -0
  810. omnibase_infra/validation/mixin_any_type_classification.py +120 -0
  811. omnibase_infra/validation/mixin_any_type_exemption.py +580 -0
  812. omnibase_infra/validation/mixin_any_type_reporting.py +106 -0
  813. omnibase_infra/validation/mixin_execution_shape_violation_checks.py +596 -0
  814. omnibase_infra/validation/mixin_node_archetype_detection.py +254 -0
  815. omnibase_infra/validation/models/__init__.py +15 -0
  816. omnibase_infra/validation/models/model_contract_lint_result.py +101 -0
  817. omnibase_infra/validation/models/model_contract_violation.py +41 -0
  818. omnibase_infra/validation/service_validation_aggregator.py +395 -0
  819. omnibase_infra/validation/validation_exemptions.yaml +2033 -0
  820. omnibase_infra/validation/validator_any_type.py +715 -0
  821. omnibase_infra/validation/validator_chain_propagation.py +839 -0
  822. omnibase_infra/validation/validator_execution_shape.py +465 -0
  823. omnibase_infra/validation/validator_localhandler.py +261 -0
  824. omnibase_infra/validation/validator_registration_security.py +410 -0
  825. omnibase_infra/validation/validator_routing_coverage.py +1020 -0
  826. omnibase_infra/validation/validator_runtime_shape.py +915 -0
  827. omnibase_infra/validation/validator_security.py +513 -0
  828. omnibase_infra/validation/validator_topic_category.py +1152 -0
  829. omnibase_infra-0.2.6.dist-info/METADATA +197 -0
  830. omnibase_infra-0.2.6.dist-info/RECORD +833 -0
  831. omnibase_infra-0.2.6.dist-info/WHEEL +4 -0
  832. omnibase_infra-0.2.6.dist-info/entry_points.txt +5 -0
  833. omnibase_infra-0.2.6.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,898 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright (c) 2025 OmniNode Team
3
+ # ruff: noqa: S104
4
+ # S104 disabled: Binding to 0.0.0.0 is intentional for Docker/K8s health checks
5
+ """HTTP Health Service for ONEX Runtime.
6
+
7
+ This module provides a minimal HTTP service for exposing health check endpoints.
8
+ It is designed to run alongside the ONEX runtime kernel to satisfy Docker/K8s
9
+ health check requirements.
10
+
11
+ The service exposes:
12
+ - GET /health: Returns runtime health status as JSON
13
+ - GET /ready: Returns readiness status as JSON (alias for /health)
14
+
15
+ Configuration:
16
+ ONEX_HTTP_PORT: Port to listen on (default: 8085)
17
+
18
+ Exports:
19
+ ServiceHealth: HTTP health check service class
20
+ DEFAULT_HTTP_HOST: Default bind address ("0.0.0.0")
21
+ DEFAULT_HTTP_PORT: Default HTTP port (8085)
22
+
23
+ Example (Direct Runtime Injection):
24
+ >>> from omnibase_infra.services.service_health import ServiceHealth
25
+ >>> from omnibase_infra.runtime import RuntimeHostProcess
26
+ >>>
27
+ >>> async def main():
28
+ ... runtime = RuntimeHostProcess()
29
+ ... server = ServiceHealth(runtime=runtime, port=8085)
30
+ ... await server.start()
31
+ ... # Server is now running
32
+ ... await server.stop()
33
+
34
+ Example (Container-Based Injection - ONEX-Compliant):
35
+ >>> from omnibase_infra.services.service_health import ServiceHealth
36
+ >>> from omnibase_core.container import ModelONEXContainer
37
+ >>>
38
+ >>> async def main():
39
+ ... container = ModelONEXContainer()
40
+ ... # Wire infrastructure services to register RuntimeHostProcess
41
+ ... await wire_infrastructure_services(container)
42
+ ... # Create ServiceHealth using async factory method
43
+ ... server = await ServiceHealth.create_from_container(container)
44
+ ... await server.start()
45
+ ... # Server is now running with container-resolved runtime
46
+ ... await server.stop()
47
+
48
+ Note:
49
+ This service uses aiohttp for async HTTP handling, which is already a
50
+ dependency of omnibase_infra for other infrastructure operations.
51
+
52
+ See Also:
53
+ - :class:`ServiceHealth` for initialization modes and container integration
54
+ - :meth:`ServiceHealth.create_from_container` for ONEX-compliant factory method
55
+ """
56
+
57
+ from __future__ import annotations
58
+
59
+ import logging
60
+ from typing import TYPE_CHECKING, Literal, cast
61
+
62
+ from aiohttp import web
63
+
64
+ from omnibase_core.types import JsonType
65
+ from omnibase_infra.enums import EnumInfraTransportType
66
+ from omnibase_infra.errors import (
67
+ ModelInfraErrorContext,
68
+ ProtocolConfigurationError,
69
+ RuntimeHostError,
70
+ )
71
+ from omnibase_infra.runtime.models.model_health_check_response import (
72
+ ModelHealthCheckResponse,
73
+ )
74
+ from omnibase_infra.utils.correlation import generate_correlation_id
75
+
76
+ if TYPE_CHECKING:
77
+ from omnibase_core.container import ModelONEXContainer
78
+ from omnibase_infra.runtime.service_runtime_host_process import RuntimeHostProcess
79
+
80
+ logger = logging.getLogger(__name__)
81
+
82
+ # Default configuration - hardcoded to avoid import-time crashes from invalid env vars
83
+ # Environment variable override is handled safely in ServiceHealth.__init__
84
+ DEFAULT_HTTP_PORT: int = 8085
85
+ DEFAULT_HTTP_HOST = "0.0.0.0"
86
+
87
+
88
+ def _get_port_from_env(default: int) -> int:
89
+ """Safely parse ONEX_HTTP_PORT from environment with fallback to default.
90
+
91
+ This function handles invalid environment variable values gracefully by
92
+ logging a warning and returning the default value, rather than raising
93
+ an exception. This prevents import-time crashes and allows the application
94
+ to start even with misconfigured environment variables.
95
+
96
+ Args:
97
+ default: The fallback port value if env var is unset or invalid.
98
+
99
+ Returns:
100
+ Parsed port value if valid and within range (1-65535), otherwise default.
101
+ """
102
+ from omnibase_infra.errors import ProtocolConfigurationError
103
+ from omnibase_infra.utils.util_env_parsing import parse_env_int
104
+
105
+ try:
106
+ return parse_env_int(
107
+ "ONEX_HTTP_PORT",
108
+ default,
109
+ min_value=1,
110
+ max_value=65535,
111
+ transport_type=EnumInfraTransportType.HTTP,
112
+ service_name="health_server",
113
+ )
114
+ except ProtocolConfigurationError as e:
115
+ logger.warning(
116
+ "Invalid ONEX_HTTP_PORT environment variable, using default %d: %s",
117
+ default,
118
+ e,
119
+ )
120
+ return default
121
+
122
+
123
+ class ServiceHealth:
124
+ """Minimal HTTP server for health check endpoints.
125
+
126
+ This server provides health check endpoints for Docker and Kubernetes
127
+ liveness/readiness probes. It delegates health status to the RuntimeHostProcess.
128
+
129
+ Attributes:
130
+ runtime: The RuntimeHostProcess instance to query for health status.
131
+ Accessed via the :attr:`runtime` property, which raises
132
+ :exc:`ProtocolConfigurationError` if not available.
133
+ port: Port to listen on (default: 8085 or ONEX_HTTP_PORT env var).
134
+ host: Host to bind to (default: 0.0.0.0 for container networking).
135
+ version: Runtime version string to include in health response.
136
+ container: Optional ONEX dependency injection container for ONEX compliance.
137
+
138
+ Container Integration (OMN-529):
139
+ ServiceHealth supports two initialization modes to accommodate both
140
+ legacy code and ONEX-compliant container-based dependency injection:
141
+
142
+ **Mode 1: Direct Runtime Injection (Legacy/Simple)**
143
+
144
+ For simple use cases or legacy code, provide the runtime directly::
145
+
146
+ runtime = RuntimeHostProcess()
147
+ server = ServiceHealth(runtime=runtime, port=8085)
148
+ await server.start()
149
+
150
+ **Mode 2: Container-Based Injection (ONEX-Compliant)**
151
+
152
+ For ONEX-compliant applications using dependency injection, use the
153
+ async factory method which resolves RuntimeHostProcess from the container::
154
+
155
+ container = ModelONEXContainer()
156
+ await wire_infrastructure_services(container)
157
+ server = await ServiceHealth.create_from_container(container)
158
+ await server.start()
159
+
160
+ **Mode 3: Hybrid (Container + Explicit Runtime)**
161
+
162
+ When you have a container but want to provide a specific runtime instance::
163
+
164
+ server = ServiceHealth(container=container, runtime=my_runtime)
165
+
166
+ This is useful for testing or when the container's registered runtime
167
+ differs from the one you want to use for health checks.
168
+
169
+ Validation:
170
+ The constructor requires at least one of ``container`` or ``runtime`` to be
171
+ provided. If neither is provided, a :exc:`ProtocolConfigurationError` is raised.
172
+ When only ``container`` is provided, use :meth:`create_from_container` to
173
+ resolve the runtime, or access the :attr:`runtime` property will raise.
174
+
175
+ Example:
176
+ >>> server = ServiceHealth(runtime=runtime, port=8085)
177
+ >>> await server.start()
178
+ >>> # curl http://localhost:8085/health
179
+ >>> await server.stop()
180
+
181
+ See Also:
182
+ - :meth:`create_from_container`: Async factory for container-based initialization
183
+ - :attr:`runtime`: Property that returns RuntimeHostProcess or raises if unavailable
184
+ """
185
+
186
+ def __init__(
187
+ self,
188
+ container: ModelONEXContainer | None = None,
189
+ runtime: RuntimeHostProcess | None = None,
190
+ port: int | None = None,
191
+ host: str = DEFAULT_HTTP_HOST,
192
+ version: str = "unknown",
193
+ ) -> None:
194
+ """Initialize the health server.
195
+
196
+ This constructor validates that at least one dependency source is provided,
197
+ but it does NOT resolve the runtime from the container. For container-based
198
+ initialization with automatic runtime resolution, use the async factory
199
+ method :meth:`create_from_container` instead.
200
+
201
+ Args:
202
+ container: Optional ONEX dependency injection container. When provided
203
+ alone (without runtime), the :attr:`runtime` property will raise
204
+ :exc:`ProtocolConfigurationError` until runtime is resolved via
205
+ :meth:`create_from_container` or set explicitly.
206
+ runtime: RuntimeHostProcess instance to delegate health checks to.
207
+ When provided, this instance is used directly for health checks.
208
+ port: Port to listen on. If None, uses ONEX_HTTP_PORT env var or 8085.
209
+ host: Host to bind to (default: 0.0.0.0 for container networking).
210
+ version: Runtime version string for health response.
211
+
212
+ Raises:
213
+ ProtocolConfigurationError: If neither ``container`` nor ``runtime``
214
+ is provided. At least one must be specified. The error includes
215
+ :class:`ModelInfraErrorContext` with transport type and operation.
216
+
217
+ Note:
218
+ **Why both container and runtime can be provided:**
219
+
220
+ The constructor accepts both parameters to support multiple use cases:
221
+
222
+ 1. **Runtime-only** (``runtime=runtime``): Legacy/simple initialization.
223
+ The runtime is used directly without container involvement.
224
+
225
+ 2. **Container-only** (``container=container``): ONEX-compliant pattern.
226
+ Use :meth:`create_from_container` to resolve runtime from container.
227
+ Direct ``__init__`` with container-only stores the container but
228
+ leaves runtime unresolved (accessing :attr:`runtime` will raise).
229
+
230
+ 3. **Both provided** (``container=container, runtime=runtime``): Hybrid
231
+ pattern for testing or custom runtime selection. The container is
232
+ stored for ONEX compliance, but the explicit runtime is used.
233
+
234
+ **Container-only initialization pattern:**
235
+
236
+ If you only have a container, use the async factory method::
237
+
238
+ # Correct: Use factory method to resolve runtime
239
+ server = await ServiceHealth.create_from_container(container)
240
+
241
+ # Incorrect: Runtime will be None, accessing it will raise
242
+ server = ServiceHealth(container=container) # Works, but...
243
+ server.runtime # Raises ProtocolConfigurationError!
244
+
245
+ Warning:
246
+ When initializing with ``container`` only (no ``runtime``), the
247
+ :attr:`runtime` property will raise :exc:`ProtocolConfigurationError`
248
+ when accessed. This is by design - synchronous ``__init__`` cannot
249
+ perform async service resolution. Use :meth:`create_from_container`
250
+ for automatic runtime resolution from the container's service registry.
251
+ """
252
+ # Store container for ONEX compliance (OMN-529)
253
+ self._container: ModelONEXContainer | None = container
254
+
255
+ # Validate that at least one dependency source is provided
256
+ if container is None and runtime is None:
257
+ context = ModelInfraErrorContext.with_correlation(
258
+ transport_type=EnumInfraTransportType.HTTP,
259
+ operation="initialize_health_server",
260
+ target_name="ServiceHealth",
261
+ )
262
+ raise ProtocolConfigurationError(
263
+ "ServiceHealth requires either 'container' or 'runtime' to be provided. "
264
+ "Use ServiceHealth(runtime=runtime) or ServiceHealth(container=container).",
265
+ context=context,
266
+ )
267
+
268
+ self._runtime: RuntimeHostProcess | None = runtime
269
+ # If port is explicitly provided, use it; otherwise parse from env var safely
270
+ self._port: int = (
271
+ port if port is not None else _get_port_from_env(DEFAULT_HTTP_PORT)
272
+ )
273
+ self._host: str = host
274
+ self._version: str = version
275
+
276
+ # Server state
277
+ self._app: web.Application | None = None
278
+ self._runner: web.AppRunner | None = None
279
+ self._site: web.TCPSite | None = None
280
+ self._is_running: bool = False
281
+
282
+ logger.debug(
283
+ "ServiceHealth initialized",
284
+ extra={
285
+ "port": self._port,
286
+ "host": self._host,
287
+ "version": self._version,
288
+ },
289
+ )
290
+
291
+ @property
292
+ def is_running(self) -> bool:
293
+ """Return True if the health server is running.
294
+
295
+ Returns:
296
+ Boolean indicating whether the server is running.
297
+ """
298
+ return self._is_running
299
+
300
+ @property
301
+ def port(self) -> int:
302
+ """Return the configured port.
303
+
304
+ Returns:
305
+ The port number the server listens on.
306
+ """
307
+ return self._port
308
+
309
+ @property
310
+ def container(self) -> ModelONEXContainer | None:
311
+ """Return the optional ONEX dependency injection container.
312
+
313
+ Returns:
314
+ The stored ModelONEXContainer instance, or None if not provided.
315
+ """
316
+ return self._container
317
+
318
+ @property
319
+ def runtime(self) -> RuntimeHostProcess:
320
+ """Return the RuntimeHostProcess instance, or raise if not available.
321
+
322
+ This property provides access to the RuntimeHostProcess that handles
323
+ the actual health status determination. The runtime must be provided
324
+ either directly via ``__init__`` or resolved from a container via
325
+ :meth:`create_from_container`.
326
+
327
+ Behavior:
328
+ - **When runtime is set**: Returns the RuntimeHostProcess instance.
329
+ - **When runtime is None**: Raises :exc:`ProtocolConfigurationError`
330
+ immediately. This happens when ``ServiceHealth(container=container)``
331
+ was called without using :meth:`create_from_container` to resolve
332
+ the runtime from the container's service registry.
333
+
334
+ Returns:
335
+ The RuntimeHostProcess instance used to determine health status.
336
+
337
+ Raises:
338
+ ProtocolConfigurationError: If runtime is not available. This occurs when:
339
+
340
+ 1. ``ServiceHealth(container=container)`` was called without runtime
341
+ and :meth:`create_from_container` was not used.
342
+
343
+ 2. The runtime was never provided or resolved.
344
+
345
+ The error includes :class:`ModelInfraErrorContext` with transport
346
+ type (HTTP), operation name, and target for debugging.
347
+
348
+ Example:
349
+ >>> # Runtime provided directly - property works
350
+ >>> server = ServiceHealth(runtime=runtime)
351
+ >>> server.runtime # Returns RuntimeHostProcess
352
+
353
+ >>> # Container-only without factory - property raises
354
+ >>> server = ServiceHealth(container=container)
355
+ >>> server.runtime # Raises ProtocolConfigurationError!
356
+
357
+ >>> # Container with factory - property works
358
+ >>> server = await ServiceHealth.create_from_container(container)
359
+ >>> server.runtime # Returns RuntimeHostProcess
360
+
361
+ See Also:
362
+ :meth:`create_from_container`: Factory method that resolves runtime
363
+ """
364
+ if self._runtime is None:
365
+ context = ModelInfraErrorContext.with_correlation(
366
+ transport_type=EnumInfraTransportType.HTTP,
367
+ operation="get_runtime",
368
+ target_name="ServiceHealth.runtime",
369
+ )
370
+ raise ProtocolConfigurationError(
371
+ "RuntimeHostProcess not available. "
372
+ "Either provide runtime during __init__ or use create_from_container().",
373
+ context=context,
374
+ )
375
+ return self._runtime
376
+
377
+ @classmethod
378
+ async def create_from_container(
379
+ cls,
380
+ container: ModelONEXContainer,
381
+ port: int | None = None,
382
+ host: str = DEFAULT_HTTP_HOST,
383
+ version: str = "unknown",
384
+ ) -> ServiceHealth:
385
+ """Create a ServiceHealth by resolving RuntimeHostProcess from container.
386
+
387
+ This is the preferred ONEX-compliant way to create a ServiceHealth when
388
+ using container-based dependency injection. It performs async service
389
+ resolution that cannot be done in the synchronous ``__init__`` method.
390
+
391
+ Parameters:
392
+ This factory method accepts 4 parameters (1 required, 3 optional):
393
+
394
+ - ``container`` (required): The ONEX container with registered services
395
+ - ``port`` (optional): Override for HTTP port
396
+ - ``host`` (optional): Override for bind address
397
+ - ``version`` (optional): Version string for health response
398
+
399
+ Args:
400
+ container: ONEX dependency injection container. Must have
401
+ RuntimeHostProcess registered in its service registry via
402
+ ``wire_infrastructure_services(container)`` or equivalent.
403
+ port: Port to listen on. If None, uses ONEX_HTTP_PORT env var or 8085.
404
+ host: Host to bind to (default: 0.0.0.0 for container networking).
405
+ version: Runtime version string for health response.
406
+
407
+ Returns:
408
+ Initialized ServiceHealth with runtime resolved from container.
409
+
410
+ Raises:
411
+ ProtocolConfigurationError: If RuntimeHostProcess cannot be resolved
412
+ from the container's service registry. This typically occurs when:
413
+
414
+ 1. ``wire_infrastructure_services()`` was not called before this method.
415
+ 2. The container's service registry does not have RuntimeHostProcess
416
+ registered.
417
+ 3. The service registry's ``resolve_service()`` method failed
418
+ for an infrastructure-related reason.
419
+
420
+ The error includes :class:`ModelInfraErrorContext` with correlation_id
421
+ for distributed tracing.
422
+
423
+ Example:
424
+ >>> container = ModelONEXContainer()
425
+ >>> await wire_infrastructure_services(container)
426
+ >>> server = await ServiceHealth.create_from_container(container)
427
+ >>> await server.start()
428
+
429
+ Example Error:
430
+ >>> container = ModelONEXContainer() # No wiring!
431
+ >>> server = await ServiceHealth.create_from_container(container)
432
+ ProtocolConfigurationError: Failed to resolve RuntimeHostProcess from container: ...
433
+ (correlation_id: 123e4567-e89b-12d3-a456-426614174000)
434
+ """
435
+ from omnibase_infra.runtime.service_runtime_host_process import (
436
+ RuntimeHostProcess,
437
+ )
438
+
439
+ correlation_id = generate_correlation_id()
440
+ try:
441
+ runtime = await container.service_registry.resolve_service(
442
+ RuntimeHostProcess
443
+ )
444
+ except Exception as e:
445
+ context = ModelInfraErrorContext(
446
+ transport_type=EnumInfraTransportType.HTTP,
447
+ operation="resolve_runtime_from_container",
448
+ target_name="ServiceHealth.create_from_container",
449
+ correlation_id=correlation_id,
450
+ )
451
+ logger.exception(
452
+ "Failed to resolve RuntimeHostProcess from container (correlation_id=%s)",
453
+ correlation_id,
454
+ extra={
455
+ "error_type": type(e).__name__,
456
+ },
457
+ )
458
+ raise ProtocolConfigurationError(
459
+ f"Failed to resolve RuntimeHostProcess from container: {e}",
460
+ context=context,
461
+ ) from e
462
+
463
+ return cls(
464
+ container=container,
465
+ runtime=runtime,
466
+ port=port,
467
+ host=host,
468
+ version=version,
469
+ )
470
+
471
+ async def start(self) -> None:
472
+ """Start the HTTP health server for Docker/Kubernetes probes.
473
+
474
+ Creates an aiohttp web application with health check endpoints and starts
475
+ listening on the configured host and port. The server exposes standardized
476
+ health check endpoints that integrate with container orchestration platforms.
477
+
478
+ Startup Process:
479
+ 1. Check if server is already running (idempotent safety check)
480
+ 2. Create aiohttp Application instance
481
+ 3. Register health check routes (/health, /ready)
482
+ 4. Initialize AppRunner and perform async setup
483
+ 5. Create TCPSite bound to configured host and port
484
+ 6. Start listening for incoming health check requests
485
+ 7. Mark server as running and log startup with correlation tracking
486
+
487
+ Health Endpoints:
488
+ - GET /health: Primary health check endpoint
489
+ - GET /ready: Readiness probe (alias for /health)
490
+
491
+ Both endpoints return JSON with:
492
+ - status: "healthy" | "degraded" | "unhealthy"
493
+ - version: Runtime kernel version
494
+ - details: Full health check details from RuntimeHostProcess
495
+
496
+ HTTP Status Codes:
497
+ - 200: Healthy or degraded (container operational)
498
+ - 503: Unhealthy (container should be restarted)
499
+
500
+ This method is idempotent - calling start() on an already running
501
+ server is safe and has no effect. This prevents double-start errors
502
+ during rapid restart scenarios.
503
+
504
+ Raises:
505
+ RuntimeHostError: If server fails to start. Common causes include:
506
+ - Port already in use (OSError with EADDRINUSE)
507
+ - Permission denied on privileged port (OSError with EACCES)
508
+ - Network interface unavailable
509
+ - Unexpected aiohttp initialization errors
510
+
511
+ All errors include:
512
+ - correlation_id: UUID for distributed tracing
513
+ - context: ModelInfraErrorContext with transport type, operation
514
+ - Original exception chaining: via "from e" for root cause analysis
515
+
516
+ Example:
517
+ >>> server = ServiceHealth(runtime=runtime, port=8085)
518
+ >>> await server.start()
519
+ >>> # Server now listening at http://0.0.0.0:8085/health
520
+ >>> # Docker can probe: curl http://localhost:8085/health
521
+
522
+ Example Error (Port In Use):
523
+ RuntimeHostError: Failed to start health server on 0.0.0.0:8085: [Errno 48] Address already in use
524
+ (correlation_id: 123e4567-e89b-12d3-a456-426614174000)
525
+
526
+ Docker Integration:
527
+ HEALTHCHECK --interval=30s --timeout=3s \\
528
+ CMD curl -f http://localhost:8085/health || exit 1
529
+ """
530
+ if self._is_running:
531
+ logger.debug("ServiceHealth already started, skipping")
532
+ return
533
+
534
+ correlation_id = generate_correlation_id()
535
+ context = ModelInfraErrorContext(
536
+ transport_type=EnumInfraTransportType.HTTP,
537
+ operation="start_health_server",
538
+ target_name=f"{self._host}:{self._port}",
539
+ correlation_id=correlation_id,
540
+ )
541
+
542
+ try:
543
+ # Create aiohttp application
544
+ self._app = web.Application()
545
+
546
+ # Register routes
547
+ self._app.router.add_get("/health", self._handle_health)
548
+ self._app.router.add_get("/ready", self._handle_health) # Alias
549
+
550
+ # Create and start runner
551
+ self._runner = web.AppRunner(self._app)
552
+ await self._runner.setup()
553
+
554
+ # Create site and start listening
555
+ self._site = web.TCPSite(
556
+ self._runner,
557
+ self._host,
558
+ self._port,
559
+ )
560
+ await self._site.start()
561
+
562
+ self._is_running = True
563
+
564
+ logger.info(
565
+ "ServiceHealth started (correlation_id=%s)",
566
+ correlation_id,
567
+ extra={
568
+ "host": self._host,
569
+ "port": self._port,
570
+ "endpoints": ["/health", "/ready"],
571
+ "version": self._version,
572
+ },
573
+ )
574
+
575
+ except OSError as e:
576
+ # Port binding failure (e.g., address already in use, permission denied)
577
+ error_msg = (
578
+ f"Failed to start health server on {self._host}:{self._port}: {e}"
579
+ )
580
+ logger.exception(
581
+ "%s (correlation_id=%s)",
582
+ error_msg,
583
+ correlation_id,
584
+ extra={
585
+ "error_type": type(e).__name__,
586
+ "errno": e.errno if hasattr(e, "errno") else None,
587
+ },
588
+ )
589
+ raise RuntimeHostError(
590
+ error_msg,
591
+ context=context,
592
+ ) from e
593
+
594
+ except Exception as e:
595
+ # Unexpected error during server startup
596
+ error_msg = f"Unexpected error starting health server: {e}"
597
+ logger.exception(
598
+ "%s (correlation_id=%s)",
599
+ error_msg,
600
+ correlation_id,
601
+ extra={
602
+ "error_type": type(e).__name__,
603
+ },
604
+ )
605
+ raise RuntimeHostError(
606
+ error_msg,
607
+ context=context,
608
+ ) from e
609
+
610
+ async def stop(self) -> None:
611
+ """Stop the HTTP health server gracefully.
612
+
613
+ Gracefully shuts down the aiohttp web server and releases all resources.
614
+ The shutdown process ensures proper cleanup of network resources, active
615
+ connections, and internal state.
616
+
617
+ Shutdown Process:
618
+ 1. Check if server is already stopped (idempotent safety check)
619
+ 2. Stop TCPSite to reject new connections
620
+ 3. Clean up AppRunner to release resources
621
+ 4. Clear Application reference
622
+ 5. Mark server as not running
623
+ 6. Log successful shutdown with correlation tracking
624
+
625
+ Resource Cleanup Order:
626
+ The cleanup follows reverse initialization order to ensure proper
627
+ resource release and prevent resource leaks:
628
+ - TCPSite (network binding)
629
+ - AppRunner (request handlers)
630
+ - Application (route definitions)
631
+
632
+ This method is idempotent - calling stop() on an already stopped
633
+ server is safe and has no effect. This prevents double-stop errors
634
+ during graceful shutdown scenarios.
635
+
636
+ Cleanup Guarantees:
637
+ - All network sockets are closed
638
+ - Active HTTP connections are terminated gracefully
639
+ - Event loop resources are released
640
+ - Server state is reset for potential restart
641
+
642
+ Example:
643
+ >>> server = ServiceHealth(runtime=runtime, port=8085)
644
+ >>> await server.start()
645
+ >>> # ... runtime operation ...
646
+ >>> await server.stop()
647
+ >>> # Server no longer listening, resources released
648
+
649
+ Exception Handling:
650
+ This method does not raise exceptions. Any errors during cleanup
651
+ are logged but do not prevent the shutdown sequence from completing.
652
+ This ensures that stop() always succeeds and the server state is
653
+ consistently marked as stopped.
654
+ """
655
+ if not self._is_running:
656
+ logger.debug("ServiceHealth already stopped, skipping")
657
+ return
658
+
659
+ correlation_id = generate_correlation_id()
660
+ logger.info(
661
+ "Stopping ServiceHealth (correlation_id=%s)",
662
+ correlation_id,
663
+ )
664
+
665
+ # Cleanup in reverse order of creation
666
+ # Stop TCPSite first to reject new connections
667
+ if self._site is not None:
668
+ try:
669
+ await self._site.stop()
670
+ except Exception as e:
671
+ logger.warning(
672
+ "Error stopping TCPSite during shutdown (correlation_id=%s)",
673
+ correlation_id,
674
+ extra={
675
+ "error_type": type(e).__name__,
676
+ "error": str(e),
677
+ },
678
+ )
679
+ self._site = None
680
+
681
+ # Clean up AppRunner to release resources
682
+ if self._runner is not None:
683
+ try:
684
+ await self._runner.cleanup()
685
+ except Exception as e:
686
+ logger.warning(
687
+ "Error cleaning up AppRunner during shutdown (correlation_id=%s)",
688
+ correlation_id,
689
+ extra={
690
+ "error_type": type(e).__name__,
691
+ "error": str(e),
692
+ },
693
+ )
694
+ self._runner = None
695
+
696
+ # Clear application reference
697
+ self._app = None
698
+ self._is_running = False
699
+
700
+ logger.info(
701
+ "ServiceHealth stopped successfully (correlation_id=%s)",
702
+ correlation_id,
703
+ )
704
+
705
+ async def _handle_health(self, request: web.Request) -> web.Response:
706
+ """Handle GET /health and GET /ready requests.
707
+
708
+ This is the main health check endpoint handler for Docker/Kubernetes
709
+ health probes. It delegates to RuntimeHostProcess.health_check() for
710
+ actual health status determination and returns a standardized JSON
711
+ response with status information and diagnostics.
712
+
713
+ Health Status Logic:
714
+ 1. Query RuntimeHostProcess for current health state
715
+ 2. Analyze health details to determine overall status
716
+ 3. Map status to appropriate HTTP status code
717
+ 4. Construct JSON response with version and diagnostics
718
+ 5. Return response to health probe client
719
+
720
+ Status Determination:
721
+ - healthy: All components operational, return HTTP 200
722
+ - degraded: Core running but some handlers failed, return HTTP 200
723
+ - unhealthy: Critical failure, return HTTP 503
724
+
725
+ Degraded State HTTP 200 Design Decision:
726
+ Degraded containers intentionally return HTTP 200 to keep them in service
727
+ rotation. This is a deliberate design choice that prioritizes investigation
728
+ over automatic restarts.
729
+
730
+ Rationale:
731
+ 1. Automatic restarts may mask recurring issues that need investigation
732
+ 2. Reduced functionality is often preferable to no functionality
733
+ 3. Cascading failures can occur if multiple containers restart simultaneously
734
+ 4. Operators can monitor degraded status via metrics/alerts and investigate
735
+
736
+ Alternative Considered:
737
+ Returning HTTP 503 would remove degraded containers from load balancer
738
+ rotation while keeping liveness probes passing. This was rejected because
739
+ it reduces capacity during partial outages when some functionality may
740
+ still be valuable to users.
741
+
742
+ Customization:
743
+ If your deployment requires removing degraded containers from rotation,
744
+ you can override this behavior by subclassing ServiceHealth and modifying
745
+ the _handle_health method, or configure your load balancer to inspect
746
+ the response body "status" field instead of relying solely on HTTP codes.
747
+
748
+ Args:
749
+ request: The incoming aiohttp HTTP request. This parameter is required
750
+ by the aiohttp handler signature but is intentionally unused in this
751
+ implementation as health checks do not require request data.
752
+
753
+ Returns:
754
+ JSON response with health status information. The HTTP status code
755
+ indicates container health to orchestration platforms:
756
+ - HTTP 200: Container is healthy or degraded (operational)
757
+ - HTTP 503: Container is unhealthy (restart recommended)
758
+
759
+ Response Format (Success):
760
+ {
761
+ "status": "healthy" | "degraded" | "unhealthy",
762
+ "version": "x.y.z",
763
+ "details": {
764
+ "healthy": bool,
765
+ "degraded": bool,
766
+ "is_running": bool,
767
+ "is_draining": bool, // True during graceful shutdown drain
768
+ "pending_message_count": int, // In-flight messages
769
+ "handlers": {...},
770
+ // Additional health check details
771
+ }
772
+ }
773
+
774
+ Response Format (Error):
775
+ {
776
+ "status": "unhealthy",
777
+ "version": "x.y.z",
778
+ "error": "Exception message",
779
+ "correlation_id": "uuid-for-tracing"
780
+ }
781
+
782
+ Docker Integration Example:
783
+ HEALTHCHECK --interval=30s --timeout=3s --retries=3 \\
784
+ CMD curl -f http://localhost:8085/health || exit 1
785
+
786
+ Kubernetes Integration Example:
787
+ livenessProbe:
788
+ httpGet:
789
+ path: /health
790
+ port: 8085
791
+ initialDelaySeconds: 30
792
+ periodSeconds: 10
793
+
794
+ Exception Handling:
795
+ If health_check() raises an exception, the handler:
796
+ 1. Logs the full exception with correlation_id for tracing
797
+ 2. Returns HTTP 503 with error details
798
+ 3. Includes correlation_id in response for debugging
799
+ This ensures health probes always receive a response even during
800
+ runtime failures, preventing indefinite probe hangs.
801
+ """
802
+ # Suppress unused argument warning - aiohttp handler signature requires request
803
+ _ = request
804
+
805
+ try:
806
+ # Get health status from runtime
807
+ health_details = await self.runtime.health_check()
808
+
809
+ # Runtime type validation: health_check() returns dict per contract
810
+ # This helps static analysis and provides runtime validation
811
+ # NOTE: Use explicit if/raise instead of assert - assertions can be
812
+ # disabled with Python's -O flag, which would skip this safety check
813
+ if not isinstance(health_details, dict):
814
+ context = ModelInfraErrorContext.with_correlation(
815
+ transport_type=EnumInfraTransportType.HTTP,
816
+ operation="validate_health_check_response",
817
+ target_name="RuntimeHostProcess.health_check",
818
+ )
819
+ raise ProtocolConfigurationError(
820
+ f"health_check() must return dict, got {type(health_details).__name__}",
821
+ context=context,
822
+ )
823
+
824
+ # Determine overall status based on health check results
825
+ is_healthy = bool(health_details.get("healthy", False))
826
+ is_degraded = bool(health_details.get("degraded", False))
827
+
828
+ if is_healthy:
829
+ status: Literal["healthy", "degraded", "unhealthy"] = "healthy"
830
+ http_status = 200
831
+ elif is_degraded:
832
+ # DESIGN DECISION: Degraded status returns HTTP 200 (not 503)
833
+ #
834
+ # Rationale: Degraded containers remain in service rotation to allow
835
+ # operators to investigate issues without triggering automatic restarts.
836
+ # The "degraded" status in the response body indicates reduced functionality
837
+ # while keeping the container operational for Docker/Kubernetes probes.
838
+ #
839
+ # Why HTTP 200 instead of 503:
840
+ # 1. Prevents cascading failures if multiple containers degrade together
841
+ # 2. Reduced functionality is often better than no functionality
842
+ # 3. Automatic restarts may mask recurring issues needing investigation
843
+ # 4. Operators can monitor "degraded" status via metrics/alerts
844
+ #
845
+ # Alternative considered: HTTP 503 would remove degraded containers from
846
+ # load balancer rotation while keeping liveness probes passing. Rejected
847
+ # because it reduces capacity during partial outages when degraded
848
+ # containers may still serve valuable traffic.
849
+ #
850
+ # Customization: To remove degraded containers from rotation, either:
851
+ # - Subclass ServiceHealth and override _handle_health()
852
+ # - Configure load balancer to inspect response body "status" field
853
+ # - Change http_status below to 503 if restart-on-degrade is preferred
854
+ status = "degraded"
855
+ http_status = 200
856
+ else:
857
+ status = "unhealthy"
858
+ http_status = 503
859
+
860
+ response = ModelHealthCheckResponse.success(
861
+ status=status,
862
+ version=self._version,
863
+ details=cast("dict[str, JsonType]", health_details),
864
+ )
865
+
866
+ return web.Response(
867
+ text=response.model_dump_json(exclude_none=True),
868
+ status=http_status,
869
+ content_type="application/json",
870
+ )
871
+
872
+ except Exception as e:
873
+ # Health check itself failed - generate correlation_id for tracing
874
+ correlation_id = generate_correlation_id()
875
+ logger.exception(
876
+ "Health check failed with exception (correlation_id=%s)",
877
+ correlation_id,
878
+ extra={
879
+ "error": str(e),
880
+ "error_type": type(e).__name__,
881
+ },
882
+ )
883
+
884
+ error_response = ModelHealthCheckResponse.failure(
885
+ version=self._version,
886
+ error=str(e),
887
+ error_type=type(e).__name__,
888
+ correlation_id=str(correlation_id),
889
+ )
890
+
891
+ return web.Response(
892
+ text=error_response.model_dump_json(exclude_none=True),
893
+ status=503,
894
+ content_type="application/json",
895
+ )
896
+
897
+
898
+ __all__: list[str] = ["DEFAULT_HTTP_HOST", "DEFAULT_HTTP_PORT", "ServiceHealth"]