omnibase_infra 0.3.1__py3-none-any.whl → 0.3.2__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 (72) hide show
  1. omnibase_infra/__init__.py +1 -1
  2. omnibase_infra/enums/__init__.py +3 -0
  3. omnibase_infra/enums/enum_consumer_group_purpose.py +9 -0
  4. omnibase_infra/enums/enum_postgres_error_code.py +188 -0
  5. omnibase_infra/handlers/registration_storage/handler_registration_storage_postgres.py +29 -20
  6. omnibase_infra/mixins/__init__.py +14 -0
  7. omnibase_infra/mixins/mixin_postgres_error_response.py +314 -0
  8. omnibase_infra/mixins/mixin_postgres_op_executor.py +298 -0
  9. omnibase_infra/models/__init__.py +3 -0
  10. omnibase_infra/{nodes/effects/models → models}/model_backend_result.py +22 -6
  11. omnibase_infra/models/projection/__init__.py +11 -0
  12. omnibase_infra/models/projection/model_contract_projection.py +170 -0
  13. omnibase_infra/models/projection/model_topic_projection.py +148 -0
  14. omnibase_infra/nodes/contract_registry_reducer/__init__.py +5 -0
  15. omnibase_infra/nodes/contract_registry_reducer/contract_registration_event_router.py +689 -0
  16. omnibase_infra/nodes/effects/__init__.py +1 -1
  17. omnibase_infra/nodes/effects/models/__init__.py +6 -4
  18. omnibase_infra/nodes/effects/models/model_registry_response.py +1 -1
  19. omnibase_infra/nodes/effects/protocol_consul_client.py +1 -1
  20. omnibase_infra/nodes/effects/protocol_postgres_adapter.py +1 -1
  21. omnibase_infra/nodes/effects/registry_effect.py +1 -1
  22. omnibase_infra/nodes/node_contract_persistence_effect/__init__.py +101 -0
  23. omnibase_infra/nodes/node_contract_persistence_effect/contract.yaml +490 -0
  24. omnibase_infra/nodes/node_contract_persistence_effect/handlers/__init__.py +74 -0
  25. omnibase_infra/nodes/node_contract_persistence_effect/handlers/handler_postgres_cleanup_topics.py +217 -0
  26. omnibase_infra/nodes/node_contract_persistence_effect/handlers/handler_postgres_contract_upsert.py +242 -0
  27. omnibase_infra/nodes/node_contract_persistence_effect/handlers/handler_postgres_deactivate.py +194 -0
  28. omnibase_infra/nodes/node_contract_persistence_effect/handlers/handler_postgres_heartbeat.py +243 -0
  29. omnibase_infra/nodes/node_contract_persistence_effect/handlers/handler_postgres_mark_stale.py +208 -0
  30. omnibase_infra/nodes/node_contract_persistence_effect/handlers/handler_postgres_topic_update.py +298 -0
  31. omnibase_infra/nodes/node_contract_persistence_effect/models/__init__.py +15 -0
  32. omnibase_infra/nodes/node_contract_persistence_effect/models/model_persistence_result.py +52 -0
  33. omnibase_infra/nodes/node_contract_persistence_effect/node.py +114 -0
  34. omnibase_infra/nodes/node_contract_persistence_effect/registry/__init__.py +27 -0
  35. omnibase_infra/nodes/node_contract_persistence_effect/registry/registry_infra_contract_persistence_effect.py +220 -0
  36. omnibase_infra/nodes/node_registry_effect/models/__init__.py +2 -2
  37. omnibase_infra/projectors/__init__.py +6 -0
  38. omnibase_infra/projectors/projection_reader_contract.py +1301 -0
  39. omnibase_infra/runtime/__init__.py +5 -0
  40. omnibase_infra/runtime/contract_registration_event_router.py +500 -0
  41. omnibase_infra/runtime/db/__init__.py +4 -0
  42. omnibase_infra/runtime/db/models/__init__.py +15 -10
  43. omnibase_infra/runtime/db/models/model_db_operation.py +40 -0
  44. omnibase_infra/runtime/db/models/model_db_param.py +24 -0
  45. omnibase_infra/runtime/db/models/model_db_repository_contract.py +40 -0
  46. omnibase_infra/runtime/db/models/model_db_return.py +26 -0
  47. omnibase_infra/runtime/db/models/model_db_safety_policy.py +32 -0
  48. omnibase_infra/runtime/intent_execution_router.py +430 -0
  49. omnibase_infra/runtime/models/__init__.py +6 -0
  50. omnibase_infra/runtime/models/model_contract_registry_config.py +41 -0
  51. omnibase_infra/runtime/models/model_intent_execution_summary.py +79 -0
  52. omnibase_infra/runtime/models/model_runtime_config.py +8 -0
  53. omnibase_infra/runtime/protocols/__init__.py +16 -0
  54. omnibase_infra/runtime/protocols/protocol_intent_executor.py +107 -0
  55. omnibase_infra/runtime/request_response_wiring.py +785 -0
  56. omnibase_infra/runtime/service_kernel.py +295 -8
  57. omnibase_infra/services/registry_api/models/__init__.py +25 -0
  58. omnibase_infra/services/registry_api/models/model_contract_ref.py +44 -0
  59. omnibase_infra/services/registry_api/models/model_contract_view.py +81 -0
  60. omnibase_infra/services/registry_api/models/model_response_contracts.py +50 -0
  61. omnibase_infra/services/registry_api/models/model_response_topics.py +50 -0
  62. omnibase_infra/services/registry_api/models/model_topic_summary.py +57 -0
  63. omnibase_infra/services/registry_api/models/model_topic_view.py +63 -0
  64. omnibase_infra/services/registry_api/routes.py +205 -6
  65. omnibase_infra/services/registry_api/service.py +528 -1
  66. omnibase_infra/validation/infra_validators.py +3 -1
  67. omnibase_infra/validation/validation_exemptions.yaml +54 -0
  68. {omnibase_infra-0.3.1.dist-info → omnibase_infra-0.3.2.dist-info}/METADATA +3 -3
  69. {omnibase_infra-0.3.1.dist-info → omnibase_infra-0.3.2.dist-info}/RECORD +72 -34
  70. {omnibase_infra-0.3.1.dist-info → omnibase_infra-0.3.2.dist-info}/WHEEL +0 -0
  71. {omnibase_infra-0.3.1.dist-info → omnibase_infra-0.3.2.dist-info}/entry_points.txt +0 -0
  72. {omnibase_infra-0.3.1.dist-info → omnibase_infra-0.3.2.dist-info}/licenses/LICENSE +0 -0
@@ -47,6 +47,9 @@ from __future__ import annotations
47
47
 
48
48
  from pydantic import BaseModel, ConfigDict, Field
49
49
 
50
+ from omnibase_infra.runtime.models.model_contract_registry_config import (
51
+ ModelContractRegistryConfig,
52
+ )
50
53
  from omnibase_infra.runtime.models.model_enabled_protocols_config import (
51
54
  ModelEnabledProtocolsConfig,
52
55
  )
@@ -72,6 +75,7 @@ class ModelRuntimeConfig(BaseModel):
72
75
  protocols: Enabled protocols configuration [RESERVED]
73
76
  logging: Logging configuration [RESERVED]
74
77
  shutdown: Shutdown configuration [ACTIVE - grace_period_seconds used]
78
+ contract_registry: Contract registry configuration [ACTIVE]
75
79
 
76
80
  Field Status Legend:
77
81
  [ACTIVE] - Currently used by kernel.py
@@ -145,6 +149,10 @@ class ModelRuntimeConfig(BaseModel):
145
149
  default_factory=ModelShutdownConfig,
146
150
  description="Shutdown configuration",
147
151
  )
152
+ contract_registry: ModelContractRegistryConfig = Field(
153
+ default_factory=ModelContractRegistryConfig,
154
+ description="Contract registry configuration",
155
+ )
148
156
 
149
157
 
150
158
  __all__: list[str] = ["ModelRuntimeConfig"]
@@ -23,15 +23,31 @@ Related:
23
23
 
24
24
  from __future__ import annotations
25
25
 
26
+ from typing import TYPE_CHECKING
27
+
26
28
  # Re-export from omnibase_core for convenience
27
29
  from omnibase_core.protocols.notifications import (
28
30
  ProtocolTransitionNotificationPublisher,
29
31
  )
32
+ from omnibase_infra.runtime.protocols.protocol_intent_executor import (
33
+ PayloadT_contra,
34
+ ProtocolIntentExecutor,
35
+ )
30
36
  from omnibase_infra.runtime.protocols.protocol_runtime_scheduler import (
31
37
  ProtocolRuntimeScheduler,
32
38
  )
33
39
 
40
+ if TYPE_CHECKING:
41
+ # IntentPayloadType is only available for type checking - it references
42
+ # models from nodes.* which aren't loaded during package initialization.
43
+ from omnibase_infra.runtime.protocols.protocol_intent_executor import (
44
+ IntentPayloadType,
45
+ )
46
+
47
+ # NOTE: IntentPayloadType is only available under TYPE_CHECKING (see above)
34
48
  __all__: list[str] = [
49
+ "PayloadT_contra",
50
+ "ProtocolIntentExecutor",
35
51
  "ProtocolRuntimeScheduler",
36
52
  "ProtocolTransitionNotificationPublisher",
37
53
  ]
@@ -0,0 +1,107 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright (c) 2025 OmniNode Team
3
+ """Protocol for intent executors in the contract persistence pipeline.
4
+
5
+ This module defines the protocol interface for intent executors that process
6
+ persistence intents from the ContractRegistryReducer.
7
+
8
+ Design:
9
+ Uses a Generic Protocol with contravariant TypeVar to properly express that
10
+ each handler accepts its specific payload type while the router can store
11
+ any handler conforming to the protocol. This avoids the need for `object`
12
+ workarounds and `cast()` at call sites.
13
+
14
+ Related:
15
+ - IntentExecutionRouter: Uses this protocol for handler routing
16
+ - OMN-1869: Implementation ticket
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ from typing import TYPE_CHECKING, Protocol, TypeVar, runtime_checkable
22
+ from uuid import UUID
23
+
24
+ if TYPE_CHECKING:
25
+ # These imports are only needed for type annotations.
26
+ # Using TYPE_CHECKING avoids circular import during package initialization
27
+ # (runtime.protocols is loaded before nodes is loaded).
28
+ from omnibase_infra.models.model_backend_result import (
29
+ ModelBackendResult,
30
+ )
31
+ from omnibase_infra.nodes.contract_registry_reducer.models import (
32
+ ModelPayloadCleanupTopicReferences,
33
+ ModelPayloadDeactivateContract,
34
+ ModelPayloadMarkStale,
35
+ ModelPayloadUpdateHeartbeat,
36
+ ModelPayloadUpdateTopic,
37
+ ModelPayloadUpsertContract,
38
+ )
39
+
40
+ # Type alias for payload types (union of all supported payloads)
41
+ # Defined inside TYPE_CHECKING since it references models only available there
42
+ IntentPayloadType = (
43
+ ModelPayloadUpsertContract
44
+ | ModelPayloadUpdateTopic
45
+ | ModelPayloadMarkStale
46
+ | ModelPayloadUpdateHeartbeat
47
+ | ModelPayloadDeactivateContract
48
+ | ModelPayloadCleanupTopicReferences
49
+ )
50
+
51
+ # Contravariant TypeVar for payload types - allows handlers with specific
52
+ # payload types to satisfy the protocol when used with broader type hints
53
+ PayloadT_contra = TypeVar("PayloadT_contra", contravariant=True)
54
+
55
+
56
+ @runtime_checkable
57
+ class ProtocolIntentExecutor(Protocol[PayloadT_contra]):
58
+ """Generic protocol for intent executors.
59
+
60
+ All persistence executors implement this interface, enabling type-safe
61
+ routing without tight coupling to specific implementations.
62
+
63
+ The protocol uses a contravariant TypeVar for the payload parameter,
64
+ which correctly expresses that:
65
+ - A handler accepting `ModelPayloadUpsertContract` can be stored where
66
+ `ProtocolIntentExecutor[Any]` is expected
67
+ - The router can call `handle()` with any payload that matches the
68
+ handler's declared payload type
69
+
70
+ Type Parameters:
71
+ PayloadT_contra: The payload type this executor accepts (contravariant).
72
+
73
+ Example:
74
+ >>> class HandlerPostgresContractUpsert:
75
+ ... async def handle(
76
+ ... self,
77
+ ... payload: ModelPayloadUpsertContract,
78
+ ... correlation_id: UUID,
79
+ ... ) -> ModelBackendResult: ...
80
+ >>>
81
+ >>> # Handler satisfies ProtocolIntentExecutor[ModelPayloadUpsertContract]
82
+ >>> # and can be stored as ProtocolIntentExecutor[Any]
83
+ >>> handlers: dict[str, ProtocolIntentExecutor[Any]] = {
84
+ ... "upsert": HandlerPostgresContractUpsert(pool),
85
+ ... }
86
+ """
87
+
88
+ async def handle(
89
+ self,
90
+ payload: PayloadT_contra,
91
+ correlation_id: UUID,
92
+ ) -> ModelBackendResult:
93
+ """Execute the handler operation.
94
+
95
+ Args:
96
+ payload: The typed payload model for this handler.
97
+ correlation_id: Request correlation ID for distributed tracing.
98
+
99
+ Returns:
100
+ ModelBackendResult with execution status.
101
+ """
102
+ ...
103
+
104
+
105
+ # NOTE: IntentPayloadType is only available under TYPE_CHECKING.
106
+ # Import it with: if TYPE_CHECKING: from ...protocol_intent_executor import IntentPayloadType
107
+ __all__ = ["PayloadT_contra", "ProtocolIntentExecutor"]