omnibase_infra 0.2.8__py3-none-any.whl → 0.2.9__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 (79) hide show
  1. omnibase_infra/__init__.py +1 -1
  2. omnibase_infra/enums/__init__.py +4 -0
  3. omnibase_infra/enums/enum_declarative_node_violation.py +102 -0
  4. omnibase_infra/event_bus/adapters/__init__.py +31 -0
  5. omnibase_infra/event_bus/adapters/adapter_protocol_event_publisher_kafka.py +517 -0
  6. omnibase_infra/mixins/mixin_async_circuit_breaker.py +113 -1
  7. omnibase_infra/models/__init__.py +9 -0
  8. omnibase_infra/models/event_bus/__init__.py +22 -0
  9. omnibase_infra/models/event_bus/model_consumer_retry_config.py +367 -0
  10. omnibase_infra/models/event_bus/model_dlq_config.py +177 -0
  11. omnibase_infra/models/event_bus/model_idempotency_config.py +131 -0
  12. omnibase_infra/models/event_bus/model_offset_policy_config.py +107 -0
  13. omnibase_infra/models/resilience/model_circuit_breaker_config.py +15 -0
  14. omnibase_infra/models/validation/__init__.py +8 -0
  15. omnibase_infra/models/validation/model_declarative_node_validation_result.py +139 -0
  16. omnibase_infra/models/validation/model_declarative_node_violation.py +169 -0
  17. omnibase_infra/nodes/architecture_validator/__init__.py +28 -7
  18. omnibase_infra/nodes/architecture_validator/constants.py +36 -0
  19. omnibase_infra/nodes/architecture_validator/handlers/__init__.py +28 -0
  20. omnibase_infra/nodes/architecture_validator/handlers/contract.yaml +120 -0
  21. omnibase_infra/nodes/architecture_validator/handlers/handler_architecture_validation.py +359 -0
  22. omnibase_infra/nodes/architecture_validator/node.py +1 -0
  23. omnibase_infra/nodes/architecture_validator/node_architecture_validator.py +48 -336
  24. omnibase_infra/nodes/node_ledger_projection_compute/__init__.py +16 -2
  25. omnibase_infra/nodes/node_ledger_projection_compute/contract.yaml +14 -4
  26. omnibase_infra/nodes/node_ledger_projection_compute/handlers/__init__.py +18 -0
  27. omnibase_infra/nodes/node_ledger_projection_compute/handlers/contract.yaml +53 -0
  28. omnibase_infra/nodes/node_ledger_projection_compute/handlers/handler_ledger_projection.py +354 -0
  29. omnibase_infra/nodes/node_ledger_projection_compute/node.py +20 -256
  30. omnibase_infra/nodes/node_registry_effect/node.py +20 -73
  31. omnibase_infra/protocols/protocol_dispatch_engine.py +90 -0
  32. omnibase_infra/runtime/__init__.py +11 -0
  33. omnibase_infra/runtime/baseline_subscriptions.py +150 -0
  34. omnibase_infra/runtime/event_bus_subcontract_wiring.py +455 -24
  35. omnibase_infra/runtime/kafka_contract_source.py +13 -5
  36. omnibase_infra/runtime/service_message_dispatch_engine.py +112 -0
  37. omnibase_infra/runtime/service_runtime_host_process.py +6 -11
  38. omnibase_infra/services/__init__.py +36 -0
  39. omnibase_infra/services/contract_publisher/__init__.py +95 -0
  40. omnibase_infra/services/contract_publisher/config.py +199 -0
  41. omnibase_infra/services/contract_publisher/errors.py +243 -0
  42. omnibase_infra/services/contract_publisher/models/__init__.py +28 -0
  43. omnibase_infra/services/contract_publisher/models/model_contract_error.py +67 -0
  44. omnibase_infra/services/contract_publisher/models/model_infra_error.py +62 -0
  45. omnibase_infra/services/contract_publisher/models/model_publish_result.py +112 -0
  46. omnibase_infra/services/contract_publisher/models/model_publish_stats.py +79 -0
  47. omnibase_infra/services/contract_publisher/service.py +617 -0
  48. omnibase_infra/services/contract_publisher/sources/__init__.py +52 -0
  49. omnibase_infra/services/contract_publisher/sources/model_discovered.py +155 -0
  50. omnibase_infra/services/contract_publisher/sources/protocol.py +101 -0
  51. omnibase_infra/services/contract_publisher/sources/source_composite.py +309 -0
  52. omnibase_infra/services/contract_publisher/sources/source_filesystem.py +174 -0
  53. omnibase_infra/services/contract_publisher/sources/source_package.py +221 -0
  54. omnibase_infra/services/observability/__init__.py +40 -0
  55. omnibase_infra/services/observability/agent_actions/__init__.py +64 -0
  56. omnibase_infra/services/observability/agent_actions/config.py +209 -0
  57. omnibase_infra/services/observability/agent_actions/consumer.py +1320 -0
  58. omnibase_infra/services/observability/agent_actions/models/__init__.py +87 -0
  59. omnibase_infra/services/observability/agent_actions/models/model_agent_action.py +142 -0
  60. omnibase_infra/services/observability/agent_actions/models/model_detection_failure.py +125 -0
  61. omnibase_infra/services/observability/agent_actions/models/model_envelope.py +85 -0
  62. omnibase_infra/services/observability/agent_actions/models/model_execution_log.py +159 -0
  63. omnibase_infra/services/observability/agent_actions/models/model_performance_metric.py +130 -0
  64. omnibase_infra/services/observability/agent_actions/models/model_routing_decision.py +138 -0
  65. omnibase_infra/services/observability/agent_actions/models/model_transformation_event.py +124 -0
  66. omnibase_infra/services/observability/agent_actions/tests/__init__.py +20 -0
  67. omnibase_infra/services/observability/agent_actions/tests/test_consumer.py +1154 -0
  68. omnibase_infra/services/observability/agent_actions/tests/test_models.py +645 -0
  69. omnibase_infra/services/observability/agent_actions/tests/test_writer.py +709 -0
  70. omnibase_infra/services/observability/agent_actions/writer_postgres.py +926 -0
  71. omnibase_infra/validation/__init__.py +12 -0
  72. omnibase_infra/validation/contracts/declarative_node.validation.yaml +143 -0
  73. omnibase_infra/validation/validation_exemptions.yaml +93 -0
  74. omnibase_infra/validation/validator_declarative_node.py +850 -0
  75. {omnibase_infra-0.2.8.dist-info → omnibase_infra-0.2.9.dist-info}/METADATA +2 -2
  76. {omnibase_infra-0.2.8.dist-info → omnibase_infra-0.2.9.dist-info}/RECORD +79 -27
  77. {omnibase_infra-0.2.8.dist-info → omnibase_infra-0.2.9.dist-info}/WHEEL +0 -0
  78. {omnibase_infra-0.2.8.dist-info → omnibase_infra-0.2.9.dist-info}/entry_points.txt +0 -0
  79. {omnibase_infra-0.2.8.dist-info → omnibase_infra-0.2.9.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,130 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright (c) 2025 OmniNode Team
3
+ """Performance Metric Model.
4
+
5
+ This module defines the model for router performance metrics consumed
6
+ from Kafka. Performance metrics capture timing and throughput data
7
+ for the agent routing system.
8
+
9
+ Design Decisions:
10
+ - extra="allow": Phase 1 flexibility - required fields typed, extras preserved
11
+ - raw_payload: Optional field to preserve complete payload for schema tightening
12
+ - created_at: Required for TTL cleanup job (Phase 2)
13
+
14
+ Idempotency:
15
+ Table: router_performance_metrics
16
+ Unique Key: id (UUID)
17
+ Conflict Action: DO NOTHING (append-only time-series)
18
+
19
+ Example:
20
+ >>> from datetime import datetime, UTC
21
+ >>> from uuid import uuid4
22
+ >>> metric = ModelPerformanceMetric(
23
+ ... id=uuid4(),
24
+ ... metric_name="routing_latency_ms",
25
+ ... metric_value=45.2,
26
+ ... created_at=datetime.now(UTC),
27
+ ... )
28
+ """
29
+
30
+ from datetime import datetime
31
+ from uuid import UUID
32
+
33
+ from pydantic import BaseModel, ConfigDict, Field
34
+
35
+ from omnibase_core.types import JsonType
36
+
37
+
38
+ class ModelPerformanceMetric(BaseModel):
39
+ """Router performance metric model.
40
+
41
+ Represents a single performance metric data point for the routing
42
+ system. Used for monitoring latency, throughput, and resource usage.
43
+
44
+ Attributes:
45
+ id: Unique identifier for this metric (idempotency key).
46
+ metric_name: Name of the metric being recorded.
47
+ metric_value: Numeric value of the metric.
48
+ created_at: Timestamp when the metric was recorded (TTL key).
49
+ correlation_id: Optional request correlation ID for trace-specific metrics.
50
+ unit: Optional unit of measurement (ms, bytes, count, etc.).
51
+ agent_name: Optional agent name if metric is agent-specific.
52
+ labels: Optional key-value labels for metric dimensionality.
53
+ metadata: Optional additional metadata about the metric.
54
+ raw_payload: Optional complete raw payload for Phase 2 schema tightening.
55
+
56
+ Example:
57
+ >>> metric = ModelPerformanceMetric(
58
+ ... id=uuid4(),
59
+ ... metric_name="agent_selection_time_ms",
60
+ ... metric_value=12.5,
61
+ ... created_at=datetime.now(UTC),
62
+ ... unit="ms",
63
+ ... agent_name="polymorphic-agent",
64
+ ... labels={"operation": "route", "status": "success"},
65
+ ... )
66
+ """
67
+
68
+ model_config = ConfigDict(
69
+ extra="allow",
70
+ from_attributes=True,
71
+ )
72
+
73
+ # ---- Required Fields ----
74
+ id: UUID = Field(
75
+ ...,
76
+ description="Unique identifier for this metric (idempotency key).",
77
+ )
78
+ metric_name: str = Field( # ONEX_EXCLUDE: entity_reference - external payload
79
+ ..., description="Name of the metric being recorded."
80
+ )
81
+ metric_value: float = Field(
82
+ ...,
83
+ description="Numeric value of the metric.",
84
+ )
85
+ created_at: datetime = Field(
86
+ ...,
87
+ description="Timestamp when the metric was recorded (TTL key).",
88
+ )
89
+
90
+ # ---- Optional Fields ----
91
+ correlation_id: UUID | None = Field(
92
+ default=None,
93
+ description="Request correlation ID for trace-specific metrics.",
94
+ )
95
+ unit: str | None = Field(
96
+ default=None,
97
+ description="Unit of measurement (ms, bytes, count, etc.).",
98
+ )
99
+ agent_name: str | None = Field(
100
+ default=None,
101
+ description="Agent name if metric is agent-specific.",
102
+ )
103
+ labels: dict[str, str] | None = Field(
104
+ default=None,
105
+ description="Key-value labels for metric dimensionality.",
106
+ )
107
+ metadata: dict[str, JsonType] | None = Field(
108
+ default=None,
109
+ description="Additional metadata about the metric.",
110
+ )
111
+ raw_payload: dict[str, JsonType] | None = Field(
112
+ default=None,
113
+ description="Complete raw payload for Phase 2 schema tightening.",
114
+ )
115
+
116
+ def __str__(self) -> str:
117
+ """Return concise string representation for logging.
118
+
119
+ Includes key identifying fields but excludes metadata and raw_payload.
120
+ """
121
+ id_short = str(self.id)[:8]
122
+ unit_part = f" {self.unit}" if self.unit else ""
123
+ agent_part = f", agent={self.agent_name}" if self.agent_name else ""
124
+ return (
125
+ f"PerformanceMetric(id={id_short}, "
126
+ f"{self.metric_name}={self.metric_value}{unit_part}{agent_part})"
127
+ )
128
+
129
+
130
+ __all__ = ["ModelPerformanceMetric"]
@@ -0,0 +1,138 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright (c) 2025 OmniNode Team
3
+ """Routing Decision Model.
4
+
5
+ This module defines the model for agent routing decision events consumed
6
+ from Kafka. Routing decisions capture the selection logic when an agent
7
+ is chosen to handle a request, including confidence scores and alternatives.
8
+
9
+ Design Decisions:
10
+ - extra="allow": Phase 1 flexibility - required fields typed, extras preserved
11
+ - raw_payload: Optional field to preserve complete payload for schema tightening
12
+ - created_at: Required for TTL cleanup job (Phase 2)
13
+
14
+ Idempotency:
15
+ Table: agent_routing_decisions
16
+ Unique Key: id (UUID)
17
+ Conflict Action: DO NOTHING (append-only audit log)
18
+
19
+ Example:
20
+ >>> from datetime import datetime, UTC
21
+ >>> from uuid import uuid4
22
+ >>> decision = ModelRoutingDecision(
23
+ ... id=uuid4(),
24
+ ... correlation_id=uuid4(),
25
+ ... selected_agent="api-architect",
26
+ ... confidence_score=0.95,
27
+ ... created_at=datetime.now(UTC),
28
+ ... )
29
+ """
30
+
31
+ from datetime import datetime
32
+ from uuid import UUID
33
+
34
+ from pydantic import BaseModel, ConfigDict, Field
35
+
36
+ from omnibase_core.types import JsonType
37
+
38
+
39
+ class ModelRoutingDecision(BaseModel):
40
+ """Agent routing decision event model.
41
+
42
+ Represents the routing decision made when selecting an agent to handle
43
+ a request. Captures the selected agent, confidence score, and alternatives
44
+ considered during routing.
45
+
46
+ Attributes:
47
+ id: Unique identifier for this decision (idempotency key).
48
+ correlation_id: Request correlation ID linking related events.
49
+ selected_agent: Name of the agent selected to handle the request.
50
+ confidence_score: Confidence score (0.0-1.0) for the selection.
51
+ created_at: Timestamp when the decision was made (TTL key).
52
+ request_type: Optional type of request being routed.
53
+ alternatives: Optional list of alternative agents considered.
54
+ routing_reason: Optional explanation for the routing decision.
55
+ domain: Optional domain classification for the request.
56
+ metadata: Optional additional metadata about the decision.
57
+ raw_payload: Optional complete raw payload for Phase 2 schema tightening.
58
+
59
+ Example:
60
+ >>> decision = ModelRoutingDecision(
61
+ ... id=uuid4(),
62
+ ... correlation_id=uuid4(),
63
+ ... selected_agent="polymorphic-agent",
64
+ ... confidence_score=0.87,
65
+ ... created_at=datetime.now(UTC),
66
+ ... routing_reason="Matched domain pattern for infrastructure tasks",
67
+ ... )
68
+ """
69
+
70
+ model_config = ConfigDict(
71
+ extra="allow",
72
+ from_attributes=True,
73
+ )
74
+
75
+ # ---- Required Fields ----
76
+ id: UUID = Field(
77
+ ...,
78
+ description="Unique identifier for this decision (idempotency key).",
79
+ )
80
+ correlation_id: UUID = Field(
81
+ ...,
82
+ description="Request correlation ID linking related events.",
83
+ )
84
+ selected_agent: str = Field(
85
+ ...,
86
+ description="Name of the agent selected to handle the request.",
87
+ )
88
+ confidence_score: float = Field(
89
+ ...,
90
+ ge=0.0,
91
+ le=1.0,
92
+ description="Confidence score for the selection. Must be between 0.0 (no confidence) and 1.0 (full confidence).",
93
+ )
94
+ created_at: datetime = Field(
95
+ ...,
96
+ description="Timestamp when the decision was made (TTL key).",
97
+ )
98
+
99
+ # ---- Optional Fields ----
100
+ request_type: str | None = Field(
101
+ default=None,
102
+ description="Type of request being routed.",
103
+ )
104
+ alternatives: list[str] | None = Field(
105
+ default=None,
106
+ description="List of alternative agents considered.",
107
+ )
108
+ routing_reason: str | None = Field(
109
+ default=None,
110
+ description="Explanation for the routing decision.",
111
+ )
112
+ domain: str | None = Field(
113
+ default=None,
114
+ description="Domain classification for the request.",
115
+ )
116
+ metadata: dict[str, JsonType] | None = Field(
117
+ default=None,
118
+ description="Additional metadata about the decision.",
119
+ )
120
+ raw_payload: dict[str, JsonType] | None = Field(
121
+ default=None,
122
+ description="Complete raw payload for Phase 2 schema tightening.",
123
+ )
124
+
125
+ def __str__(self) -> str:
126
+ """Return concise string representation for logging.
127
+
128
+ Includes key identifying fields but excludes metadata and raw_payload.
129
+ """
130
+ id_short = str(self.id)[:8]
131
+ domain_part = f", domain={self.domain}" if self.domain else ""
132
+ return (
133
+ f"RoutingDecision(id={id_short}, agent={self.selected_agent}, "
134
+ f"confidence={self.confidence_score:.2f}{domain_part})"
135
+ )
136
+
137
+
138
+ __all__ = ["ModelRoutingDecision"]
@@ -0,0 +1,124 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright (c) 2025 OmniNode Team
3
+ """Transformation Event Model.
4
+
5
+ This module defines the model for agent transformation events consumed
6
+ from Kafka. Transformation events capture when an agent transforms into
7
+ a specialized form (e.g., polymorphic agent becoming api-architect).
8
+
9
+ Design Decisions:
10
+ - extra="allow": Phase 1 flexibility - required fields typed, extras preserved
11
+ - raw_payload: Optional field to preserve complete payload for schema tightening
12
+ - created_at: Required for TTL cleanup job (Phase 2)
13
+
14
+ Idempotency:
15
+ Table: agent_transformation_events
16
+ Unique Key: id (UUID)
17
+ Conflict Action: DO NOTHING (append-only audit log)
18
+
19
+ Example:
20
+ >>> from datetime import datetime, UTC
21
+ >>> from uuid import uuid4
22
+ >>> event = ModelTransformationEvent(
23
+ ... id=uuid4(),
24
+ ... correlation_id=uuid4(),
25
+ ... source_agent="polymorphic-agent",
26
+ ... target_agent="api-architect",
27
+ ... created_at=datetime.now(UTC),
28
+ ... )
29
+ """
30
+
31
+ from datetime import datetime
32
+ from uuid import UUID
33
+
34
+ from pydantic import BaseModel, ConfigDict, Field
35
+
36
+ from omnibase_core.types import JsonType
37
+
38
+
39
+ class ModelTransformationEvent(BaseModel):
40
+ """Agent transformation event model.
41
+
42
+ Represents a transformation from one agent type to another, typically
43
+ when a polymorphic agent specializes into a domain-specific agent.
44
+
45
+ Attributes:
46
+ id: Unique identifier for this event (idempotency key).
47
+ correlation_id: Request correlation ID linking related events.
48
+ source_agent: Name of the original agent before transformation.
49
+ target_agent: Name of the agent after transformation.
50
+ created_at: Timestamp when the transformation occurred (TTL key).
51
+ trigger: Optional trigger that caused the transformation.
52
+ context: Optional context information about the transformation.
53
+ metadata: Optional additional metadata about the transformation.
54
+ raw_payload: Optional complete raw payload for Phase 2 schema tightening.
55
+
56
+ Example:
57
+ >>> event = ModelTransformationEvent(
58
+ ... id=uuid4(),
59
+ ... correlation_id=uuid4(),
60
+ ... source_agent="polymorphic-agent",
61
+ ... target_agent="debug-database",
62
+ ... created_at=datetime.now(UTC),
63
+ ... trigger="User requested database debugging",
64
+ ... )
65
+ """
66
+
67
+ model_config = ConfigDict(
68
+ extra="allow",
69
+ from_attributes=True,
70
+ )
71
+
72
+ # ---- Required Fields ----
73
+ id: UUID = Field(
74
+ ...,
75
+ description="Unique identifier for this event (idempotency key).",
76
+ )
77
+ correlation_id: UUID = Field(
78
+ ...,
79
+ description="Request correlation ID linking related events.",
80
+ )
81
+ source_agent: str = Field(
82
+ ...,
83
+ description="Name of the original agent before transformation.",
84
+ )
85
+ target_agent: str = Field(
86
+ ...,
87
+ description="Name of the agent after transformation.",
88
+ )
89
+ created_at: datetime = Field(
90
+ ...,
91
+ description="Timestamp when the transformation occurred (TTL key).",
92
+ )
93
+
94
+ # ---- Optional Fields ----
95
+ trigger: str | None = Field(
96
+ default=None,
97
+ description="Trigger that caused the transformation.",
98
+ )
99
+ context: str | None = Field(
100
+ default=None,
101
+ description="Context information about the transformation.",
102
+ )
103
+ metadata: dict[str, JsonType] | None = Field(
104
+ default=None,
105
+ description="Additional metadata about the transformation.",
106
+ )
107
+ raw_payload: dict[str, JsonType] | None = Field(
108
+ default=None,
109
+ description="Complete raw payload for Phase 2 schema tightening.",
110
+ )
111
+
112
+ def __str__(self) -> str:
113
+ """Return concise string representation for logging.
114
+
115
+ Includes key identifying fields but excludes metadata and raw_payload.
116
+ """
117
+ id_short = str(self.id)[:8]
118
+ return (
119
+ f"TransformationEvent(id={id_short}, "
120
+ f"source={self.source_agent}, target={self.target_agent})"
121
+ )
122
+
123
+
124
+ __all__ = ["ModelTransformationEvent"]
@@ -0,0 +1,20 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright (c) 2025 OmniNode Team
3
+ """Unit tests for agent_actions observability consumer.
4
+
5
+ This package contains unit tests for the agent_actions observability
6
+ consumer, including model validation, PostgreSQL writer, and Kafka consumer.
7
+
8
+ Test Categories:
9
+ - test_models: Model validation (strict envelope, flexible payloads)
10
+ - test_writer: PostgreSQL writer with idempotency and circuit breaker
11
+ - test_consumer: Kafka consumer with offset tracking and health checks
12
+
13
+ Running Tests:
14
+ pytest src/omnibase_infra/services/observability/agent_actions/tests/
15
+
16
+ Related Tickets:
17
+ - OMN-1743: Migrate agent_actions_consumer to omnibase_infra
18
+ """
19
+
20
+ __all__: list[str] = []