omnibase_infra 0.3.1__py3-none-any.whl → 0.4.0__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.
- omnibase_infra/__init__.py +1 -1
- omnibase_infra/enums/__init__.py +3 -0
- omnibase_infra/enums/enum_consumer_group_purpose.py +9 -0
- omnibase_infra/enums/enum_postgres_error_code.py +188 -0
- omnibase_infra/errors/__init__.py +4 -0
- omnibase_infra/errors/error_infra.py +60 -0
- omnibase_infra/handlers/__init__.py +3 -0
- omnibase_infra/handlers/handler_slack_webhook.py +426 -0
- omnibase_infra/handlers/models/__init__.py +14 -0
- omnibase_infra/handlers/models/enum_alert_severity.py +36 -0
- omnibase_infra/handlers/models/model_slack_alert.py +24 -0
- omnibase_infra/handlers/models/model_slack_alert_payload.py +77 -0
- omnibase_infra/handlers/models/model_slack_alert_result.py +73 -0
- omnibase_infra/handlers/registration_storage/handler_registration_storage_postgres.py +29 -20
- omnibase_infra/mixins/__init__.py +14 -0
- omnibase_infra/mixins/mixin_node_introspection.py +42 -20
- omnibase_infra/mixins/mixin_postgres_error_response.py +314 -0
- omnibase_infra/mixins/mixin_postgres_op_executor.py +298 -0
- omnibase_infra/models/__init__.py +3 -0
- omnibase_infra/models/discovery/model_dependency_spec.py +1 -0
- omnibase_infra/models/discovery/model_discovered_capabilities.py +1 -1
- omnibase_infra/models/discovery/model_introspection_config.py +28 -1
- omnibase_infra/models/discovery/model_introspection_performance_metrics.py +1 -0
- omnibase_infra/models/discovery/model_introspection_task_config.py +1 -0
- omnibase_infra/{nodes/effects/models → models}/model_backend_result.py +22 -6
- omnibase_infra/models/projection/__init__.py +11 -0
- omnibase_infra/models/projection/model_contract_projection.py +170 -0
- omnibase_infra/models/projection/model_topic_projection.py +148 -0
- omnibase_infra/models/runtime/__init__.py +4 -0
- omnibase_infra/models/runtime/model_resolved_dependencies.py +116 -0
- omnibase_infra/nodes/contract_registry_reducer/__init__.py +5 -0
- omnibase_infra/nodes/contract_registry_reducer/contract.yaml +6 -5
- omnibase_infra/nodes/contract_registry_reducer/contract_registration_event_router.py +689 -0
- omnibase_infra/nodes/contract_registry_reducer/reducer.py +9 -26
- omnibase_infra/nodes/effects/__init__.py +1 -1
- omnibase_infra/nodes/effects/models/__init__.py +6 -4
- omnibase_infra/nodes/effects/models/model_registry_response.py +1 -1
- omnibase_infra/nodes/effects/protocol_consul_client.py +1 -1
- omnibase_infra/nodes/effects/protocol_postgres_adapter.py +1 -1
- omnibase_infra/nodes/effects/registry_effect.py +1 -1
- omnibase_infra/nodes/node_contract_persistence_effect/__init__.py +101 -0
- omnibase_infra/nodes/node_contract_persistence_effect/contract.yaml +490 -0
- omnibase_infra/nodes/node_contract_persistence_effect/handlers/__init__.py +74 -0
- omnibase_infra/nodes/node_contract_persistence_effect/handlers/handler_postgres_cleanup_topics.py +217 -0
- omnibase_infra/nodes/node_contract_persistence_effect/handlers/handler_postgres_contract_upsert.py +242 -0
- omnibase_infra/nodes/node_contract_persistence_effect/handlers/handler_postgres_deactivate.py +194 -0
- omnibase_infra/nodes/node_contract_persistence_effect/handlers/handler_postgres_heartbeat.py +243 -0
- omnibase_infra/nodes/node_contract_persistence_effect/handlers/handler_postgres_mark_stale.py +208 -0
- omnibase_infra/nodes/node_contract_persistence_effect/handlers/handler_postgres_topic_update.py +298 -0
- omnibase_infra/nodes/node_contract_persistence_effect/models/__init__.py +15 -0
- omnibase_infra/nodes/node_contract_persistence_effect/models/model_persistence_result.py +52 -0
- omnibase_infra/nodes/node_contract_persistence_effect/node.py +131 -0
- omnibase_infra/nodes/node_contract_persistence_effect/registry/__init__.py +27 -0
- omnibase_infra/nodes/node_contract_persistence_effect/registry/registry_infra_contract_persistence_effect.py +251 -0
- omnibase_infra/nodes/node_registration_orchestrator/models/model_postgres_intent_payload.py +8 -12
- omnibase_infra/nodes/node_registry_effect/models/__init__.py +2 -2
- omnibase_infra/nodes/node_slack_alerter_effect/__init__.py +33 -0
- omnibase_infra/nodes/node_slack_alerter_effect/contract.yaml +291 -0
- omnibase_infra/nodes/node_slack_alerter_effect/node.py +106 -0
- omnibase_infra/projectors/__init__.py +6 -0
- omnibase_infra/projectors/projection_reader_contract.py +1301 -0
- omnibase_infra/runtime/__init__.py +12 -0
- omnibase_infra/runtime/baseline_subscriptions.py +13 -6
- omnibase_infra/runtime/contract_dependency_resolver.py +455 -0
- omnibase_infra/runtime/contract_registration_event_router.py +500 -0
- omnibase_infra/runtime/db/__init__.py +4 -0
- omnibase_infra/runtime/db/models/__init__.py +15 -10
- omnibase_infra/runtime/db/models/model_db_operation.py +40 -0
- omnibase_infra/runtime/db/models/model_db_param.py +24 -0
- omnibase_infra/runtime/db/models/model_db_repository_contract.py +40 -0
- omnibase_infra/runtime/db/models/model_db_return.py +26 -0
- omnibase_infra/runtime/db/models/model_db_safety_policy.py +32 -0
- omnibase_infra/runtime/emit_daemon/event_registry.py +34 -22
- omnibase_infra/runtime/event_bus_subcontract_wiring.py +63 -23
- omnibase_infra/runtime/intent_execution_router.py +430 -0
- omnibase_infra/runtime/models/__init__.py +6 -0
- omnibase_infra/runtime/models/model_contract_registry_config.py +41 -0
- omnibase_infra/runtime/models/model_intent_execution_summary.py +79 -0
- omnibase_infra/runtime/models/model_runtime_config.py +8 -0
- omnibase_infra/runtime/protocols/__init__.py +16 -0
- omnibase_infra/runtime/protocols/protocol_intent_executor.py +107 -0
- omnibase_infra/runtime/publisher_topic_scoped.py +16 -11
- omnibase_infra/runtime/registry_policy.py +29 -15
- omnibase_infra/runtime/request_response_wiring.py +793 -0
- omnibase_infra/runtime/service_kernel.py +295 -8
- omnibase_infra/runtime/service_runtime_host_process.py +149 -5
- omnibase_infra/runtime/util_version.py +5 -1
- omnibase_infra/schemas/schema_latency_baseline.sql +135 -0
- omnibase_infra/services/contract_publisher/config.py +4 -4
- omnibase_infra/services/contract_publisher/service.py +8 -5
- omnibase_infra/services/observability/injection_effectiveness/__init__.py +67 -0
- omnibase_infra/services/observability/injection_effectiveness/config.py +295 -0
- omnibase_infra/services/observability/injection_effectiveness/consumer.py +1461 -0
- omnibase_infra/services/observability/injection_effectiveness/models/__init__.py +32 -0
- omnibase_infra/services/observability/injection_effectiveness/models/model_agent_match.py +79 -0
- omnibase_infra/services/observability/injection_effectiveness/models/model_context_utilization.py +118 -0
- omnibase_infra/services/observability/injection_effectiveness/models/model_latency_breakdown.py +107 -0
- omnibase_infra/services/observability/injection_effectiveness/models/model_pattern_utilization.py +46 -0
- omnibase_infra/services/observability/injection_effectiveness/writer_postgres.py +596 -0
- omnibase_infra/services/registry_api/models/__init__.py +25 -0
- omnibase_infra/services/registry_api/models/model_contract_ref.py +44 -0
- omnibase_infra/services/registry_api/models/model_contract_view.py +81 -0
- omnibase_infra/services/registry_api/models/model_response_contracts.py +50 -0
- omnibase_infra/services/registry_api/models/model_response_topics.py +50 -0
- omnibase_infra/services/registry_api/models/model_topic_summary.py +57 -0
- omnibase_infra/services/registry_api/models/model_topic_view.py +63 -0
- omnibase_infra/services/registry_api/routes.py +205 -6
- omnibase_infra/services/registry_api/service.py +528 -1
- omnibase_infra/utils/__init__.py +7 -0
- omnibase_infra/utils/util_db_error_context.py +292 -0
- omnibase_infra/validation/infra_validators.py +3 -1
- omnibase_infra/validation/validation_exemptions.yaml +65 -0
- {omnibase_infra-0.3.1.dist-info → omnibase_infra-0.4.0.dist-info}/METADATA +3 -3
- {omnibase_infra-0.3.1.dist-info → omnibase_infra-0.4.0.dist-info}/RECORD +117 -58
- {omnibase_infra-0.3.1.dist-info → omnibase_infra-0.4.0.dist-info}/WHEEL +0 -0
- {omnibase_infra-0.3.1.dist-info → omnibase_infra-0.4.0.dist-info}/entry_points.txt +0 -0
- {omnibase_infra-0.3.1.dist-info → omnibase_infra-0.4.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2025 OmniNode Team
|
|
3
|
+
"""Pydantic models for injection effectiveness events.
|
|
4
|
+
|
|
5
|
+
These models correspond to the event payloads emitted by OMN-1889
|
|
6
|
+
(omniclaude hooks) and consumed by OMN-1890 (this consumer).
|
|
7
|
+
|
|
8
|
+
Event Types:
|
|
9
|
+
- ModelContextUtilizationEvent: Context utilization detection results
|
|
10
|
+
- ModelAgentMatchEvent: Agent routing accuracy metrics
|
|
11
|
+
- ModelLatencyBreakdownEvent: Per-prompt latency breakdowns
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from omnibase_infra.services.observability.injection_effectiveness.models.model_agent_match import (
|
|
15
|
+
ModelAgentMatchEvent,
|
|
16
|
+
)
|
|
17
|
+
from omnibase_infra.services.observability.injection_effectiveness.models.model_context_utilization import (
|
|
18
|
+
ModelContextUtilizationEvent,
|
|
19
|
+
)
|
|
20
|
+
from omnibase_infra.services.observability.injection_effectiveness.models.model_latency_breakdown import (
|
|
21
|
+
ModelLatencyBreakdownEvent,
|
|
22
|
+
)
|
|
23
|
+
from omnibase_infra.services.observability.injection_effectiveness.models.model_pattern_utilization import (
|
|
24
|
+
ModelPatternUtilization,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"ModelAgentMatchEvent",
|
|
29
|
+
"ModelContextUtilizationEvent",
|
|
30
|
+
"ModelLatencyBreakdownEvent",
|
|
31
|
+
"ModelPatternUtilization",
|
|
32
|
+
]
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2025 OmniNode Team
|
|
3
|
+
"""Agent match event model.
|
|
4
|
+
|
|
5
|
+
Represents the payload from onex.evt.omniclaude.agent-match.v1 topic.
|
|
6
|
+
Tracks agent routing accuracy with graded scoring (replaces boolean match).
|
|
7
|
+
|
|
8
|
+
Related Tickets:
|
|
9
|
+
- OMN-1889: Emit injection metrics + utilization signal (producer)
|
|
10
|
+
- OMN-1890: Store injection metrics with corrected schema (consumer)
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from datetime import datetime
|
|
16
|
+
from typing import Literal
|
|
17
|
+
from uuid import UUID, uuid4
|
|
18
|
+
|
|
19
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ModelAgentMatchEvent(BaseModel):
|
|
23
|
+
"""Agent match event from omniclaude hooks.
|
|
24
|
+
|
|
25
|
+
Emitted to report how well the predicted agent matched the actual
|
|
26
|
+
agent used in the session. Uses graded scoring (0.0-1.0) instead
|
|
27
|
+
of simple boolean match for more nuanced analysis.
|
|
28
|
+
|
|
29
|
+
This event populates:
|
|
30
|
+
- injection_effectiveness table (agent match fields)
|
|
31
|
+
|
|
32
|
+
Scoring Logic:
|
|
33
|
+
- 1.0: Exact match (expected == actual)
|
|
34
|
+
- 0.5-0.9: Partial match (same category, different variant)
|
|
35
|
+
- 0.0: Complete mismatch (different category)
|
|
36
|
+
|
|
37
|
+
Attributes:
|
|
38
|
+
event_type: Event type discriminator.
|
|
39
|
+
session_id: Session identifier for correlation.
|
|
40
|
+
correlation_id: Request correlation ID for tracing.
|
|
41
|
+
agent_match_score: Graded match score (0.0-1.0).
|
|
42
|
+
expected_agent: Agent predicted by routing system.
|
|
43
|
+
actual_agent: Agent actually used in session.
|
|
44
|
+
created_at: Event timestamp.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
model_config = ConfigDict(frozen=True, extra="forbid", from_attributes=True)
|
|
48
|
+
|
|
49
|
+
event_type: Literal["agent_match"] = Field(
|
|
50
|
+
default="agent_match",
|
|
51
|
+
description="Event type discriminator",
|
|
52
|
+
)
|
|
53
|
+
session_id: UUID = Field(..., description="Session identifier")
|
|
54
|
+
correlation_id: UUID = Field(
|
|
55
|
+
default_factory=uuid4,
|
|
56
|
+
description="Correlation ID for tracing",
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Agent matching (graded 0.0-1.0)
|
|
60
|
+
agent_match_score: float = Field(
|
|
61
|
+
...,
|
|
62
|
+
ge=0.0,
|
|
63
|
+
le=1.0,
|
|
64
|
+
description="Graded match score 0.0-1.0",
|
|
65
|
+
)
|
|
66
|
+
expected_agent: str | None = Field(
|
|
67
|
+
default=None,
|
|
68
|
+
description="Agent predicted by routing system",
|
|
69
|
+
)
|
|
70
|
+
actual_agent: str | None = Field(
|
|
71
|
+
default=None,
|
|
72
|
+
description="Agent actually used in session",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# Timestamp
|
|
76
|
+
created_at: datetime = Field(
|
|
77
|
+
...,
|
|
78
|
+
description="Event timestamp",
|
|
79
|
+
)
|
omnibase_infra/services/observability/injection_effectiveness/models/model_context_utilization.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2025 OmniNode Team
|
|
3
|
+
"""Context utilization event model.
|
|
4
|
+
|
|
5
|
+
Represents the payload from onex.evt.omniclaude.context-utilization.v1 topic.
|
|
6
|
+
Tracks whether injected context was actually used in the Claude response.
|
|
7
|
+
|
|
8
|
+
Related Tickets:
|
|
9
|
+
- OMN-1889: Emit injection metrics + utilization signal (producer)
|
|
10
|
+
- OMN-1890: Store injection metrics with corrected schema (consumer)
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from datetime import datetime
|
|
16
|
+
from typing import Literal
|
|
17
|
+
from uuid import UUID, uuid4
|
|
18
|
+
|
|
19
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
20
|
+
|
|
21
|
+
from omnibase_infra.services.observability.injection_effectiveness.models.model_pattern_utilization import (
|
|
22
|
+
ModelPatternUtilization,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ModelContextUtilizationEvent(BaseModel):
|
|
27
|
+
"""Context utilization event from omniclaude hooks.
|
|
28
|
+
|
|
29
|
+
Emitted at session end to report how much of the injected context
|
|
30
|
+
was actually utilized in Claude's responses.
|
|
31
|
+
|
|
32
|
+
This event populates:
|
|
33
|
+
- injection_effectiveness table (utilization fields)
|
|
34
|
+
- pattern_hit_rates table (per-pattern breakdown)
|
|
35
|
+
|
|
36
|
+
Attributes:
|
|
37
|
+
event_type: Event type discriminator.
|
|
38
|
+
session_id: Session identifier for correlation.
|
|
39
|
+
correlation_id: Request correlation ID for tracing.
|
|
40
|
+
cohort: A/B test cohort assignment.
|
|
41
|
+
cohort_identity_type: How cohort was assigned.
|
|
42
|
+
total_injected_tokens: Total tokens injected in session.
|
|
43
|
+
patterns_injected: Number of patterns injected.
|
|
44
|
+
utilization_score: Overall utilization score (0.0-1.0).
|
|
45
|
+
utilization_method: Detection method used.
|
|
46
|
+
injected_identifiers_count: Identifiers in injected context.
|
|
47
|
+
reused_identifiers_count: Identifiers found in response.
|
|
48
|
+
pattern_utilizations: Per-pattern utilization breakdown.
|
|
49
|
+
created_at: Event timestamp.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
model_config = ConfigDict(frozen=True, extra="forbid", from_attributes=True)
|
|
53
|
+
|
|
54
|
+
event_type: Literal["context_utilization"] = Field(
|
|
55
|
+
default="context_utilization",
|
|
56
|
+
description="Event type discriminator",
|
|
57
|
+
)
|
|
58
|
+
session_id: UUID = Field(..., description="Session identifier")
|
|
59
|
+
correlation_id: UUID = Field(
|
|
60
|
+
default_factory=uuid4,
|
|
61
|
+
description="Correlation ID for tracing",
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# A/B Testing
|
|
65
|
+
cohort: Literal["control", "treatment"] | None = Field(
|
|
66
|
+
default=None,
|
|
67
|
+
description="A/B test cohort",
|
|
68
|
+
)
|
|
69
|
+
cohort_identity_type: Literal["user_id", "repo_path", "session_id"] | None = Field(
|
|
70
|
+
default=None,
|
|
71
|
+
description="Identity type used for cohort assignment",
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# Injection metrics
|
|
75
|
+
total_injected_tokens: int = Field(
|
|
76
|
+
default=0,
|
|
77
|
+
ge=0,
|
|
78
|
+
description="Total tokens injected in session",
|
|
79
|
+
)
|
|
80
|
+
patterns_injected: int = Field(
|
|
81
|
+
default=0,
|
|
82
|
+
ge=0,
|
|
83
|
+
description="Number of patterns injected",
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
# Utilization (heuristic-based, NOT token attribution)
|
|
87
|
+
utilization_score: float = Field(
|
|
88
|
+
...,
|
|
89
|
+
ge=0.0,
|
|
90
|
+
le=1.0,
|
|
91
|
+
description="Overall utilization score 0.0-1.0",
|
|
92
|
+
)
|
|
93
|
+
utilization_method: str = Field(
|
|
94
|
+
...,
|
|
95
|
+
description="Detection method: identifier_match, semantic, or timeout",
|
|
96
|
+
)
|
|
97
|
+
injected_identifiers_count: int = Field(
|
|
98
|
+
default=0,
|
|
99
|
+
ge=0,
|
|
100
|
+
description="Number of identifiers in injected context",
|
|
101
|
+
)
|
|
102
|
+
reused_identifiers_count: int = Field(
|
|
103
|
+
default=0,
|
|
104
|
+
ge=0,
|
|
105
|
+
description="Number of identifiers found in response",
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# Per-pattern breakdown
|
|
109
|
+
pattern_utilizations: tuple[ModelPatternUtilization, ...] = Field(
|
|
110
|
+
default_factory=tuple,
|
|
111
|
+
description="Per-pattern utilization metrics",
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
# Timestamp
|
|
115
|
+
created_at: datetime = Field(
|
|
116
|
+
...,
|
|
117
|
+
description="Event timestamp",
|
|
118
|
+
)
|
omnibase_infra/services/observability/injection_effectiveness/models/model_latency_breakdown.py
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2025 OmniNode Team
|
|
3
|
+
"""Latency breakdown event model.
|
|
4
|
+
|
|
5
|
+
Represents the payload from onex.evt.omniclaude.latency-breakdown.v1 topic.
|
|
6
|
+
Tracks detailed timing including user-perceived latency per prompt.
|
|
7
|
+
|
|
8
|
+
Related Tickets:
|
|
9
|
+
- OMN-1889: Emit injection metrics + utilization signal (producer)
|
|
10
|
+
- OMN-1890: Store injection metrics with corrected schema (consumer)
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from datetime import datetime
|
|
16
|
+
from typing import Literal
|
|
17
|
+
from uuid import UUID, uuid4
|
|
18
|
+
|
|
19
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ModelLatencyBreakdownEvent(BaseModel):
|
|
23
|
+
"""Latency breakdown event from omniclaude hooks.
|
|
24
|
+
|
|
25
|
+
Emitted per-prompt to report detailed latency breakdowns including
|
|
26
|
+
internal timings and user-perceived latency.
|
|
27
|
+
|
|
28
|
+
This event populates:
|
|
29
|
+
- latency_breakdowns table (per-prompt row)
|
|
30
|
+
- injection_effectiveness table (MAX aggregation for user_visible_latency_ms)
|
|
31
|
+
|
|
32
|
+
Attributes:
|
|
33
|
+
event_type: Event type discriminator.
|
|
34
|
+
session_id: Session identifier for correlation.
|
|
35
|
+
correlation_id: Request correlation ID for tracing.
|
|
36
|
+
prompt_id: Unique prompt identifier from emitter.
|
|
37
|
+
cohort: A/B test cohort assignment.
|
|
38
|
+
cache_hit: Whether this prompt benefited from cache.
|
|
39
|
+
routing_latency_ms: Time spent in agent routing.
|
|
40
|
+
retrieval_latency_ms: Time spent retrieving context.
|
|
41
|
+
injection_latency_ms: Time spent injecting context.
|
|
42
|
+
user_latency_ms: User-perceived latency for this prompt.
|
|
43
|
+
emitted_at: Event timestamp from producer.
|
|
44
|
+
created_at: Event timestamp (ingest time).
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
model_config = ConfigDict(frozen=True, extra="forbid", from_attributes=True)
|
|
48
|
+
|
|
49
|
+
event_type: Literal["latency_breakdown"] = Field(
|
|
50
|
+
default="latency_breakdown",
|
|
51
|
+
description="Event type discriminator",
|
|
52
|
+
)
|
|
53
|
+
session_id: UUID = Field(..., description="Session identifier")
|
|
54
|
+
correlation_id: UUID = Field(
|
|
55
|
+
default_factory=uuid4,
|
|
56
|
+
description="Correlation ID for tracing",
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Prompt identification (UUID instead of index for uniqueness)
|
|
60
|
+
prompt_id: UUID = Field(
|
|
61
|
+
...,
|
|
62
|
+
description="Unique prompt identifier from emitter",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# A/B Testing (denormalized for fast queries)
|
|
66
|
+
cohort: Literal["control", "treatment"] | None = Field(
|
|
67
|
+
default=None,
|
|
68
|
+
description="A/B test cohort",
|
|
69
|
+
)
|
|
70
|
+
cache_hit: bool = Field(
|
|
71
|
+
default=False,
|
|
72
|
+
description="Whether this prompt benefited from cached context",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# Internal timings (ms) - nullable as not all prompts have all timings
|
|
76
|
+
routing_latency_ms: int | None = Field(
|
|
77
|
+
default=None,
|
|
78
|
+
ge=0,
|
|
79
|
+
description="Time spent in agent routing (ms)",
|
|
80
|
+
)
|
|
81
|
+
retrieval_latency_ms: int | None = Field(
|
|
82
|
+
default=None,
|
|
83
|
+
ge=0,
|
|
84
|
+
description="Time spent retrieving context (ms)",
|
|
85
|
+
)
|
|
86
|
+
injection_latency_ms: int | None = Field(
|
|
87
|
+
default=None,
|
|
88
|
+
ge=0,
|
|
89
|
+
description="Time spent injecting context (ms)",
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
# User-perceived latency (required)
|
|
93
|
+
user_latency_ms: int = Field(
|
|
94
|
+
...,
|
|
95
|
+
ge=0,
|
|
96
|
+
description="User-perceived latency for this prompt (ms)",
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# Timestamps
|
|
100
|
+
emitted_at: datetime | None = Field(
|
|
101
|
+
default=None,
|
|
102
|
+
description="Event timestamp from producer (for drift analysis)",
|
|
103
|
+
)
|
|
104
|
+
created_at: datetime = Field(
|
|
105
|
+
...,
|
|
106
|
+
description="Event timestamp (ingest time)",
|
|
107
|
+
)
|
omnibase_infra/services/observability/injection_effectiveness/models/model_pattern_utilization.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2025 OmniNode Team
|
|
3
|
+
"""Pattern utilization model.
|
|
4
|
+
|
|
5
|
+
Represents per-pattern utilization metrics within a context utilization event.
|
|
6
|
+
|
|
7
|
+
Related Tickets:
|
|
8
|
+
- OMN-1889: Emit injection metrics + utilization signal (producer)
|
|
9
|
+
- OMN-1890: Store injection metrics with corrected schema (consumer)
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from uuid import UUID
|
|
15
|
+
|
|
16
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ModelPatternUtilization(BaseModel):
|
|
20
|
+
"""Per-pattern utilization metrics.
|
|
21
|
+
|
|
22
|
+
Represents utilization data for a single injected pattern, enabling
|
|
23
|
+
pattern-level effectiveness analysis.
|
|
24
|
+
|
|
25
|
+
Attributes:
|
|
26
|
+
pattern_id: UUID identifier for the injected pattern.
|
|
27
|
+
utilization_score: How much of the pattern was used (0.0-1.0).
|
|
28
|
+
utilization_method: Detection method used for this pattern.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
model_config = ConfigDict(frozen=True, extra="forbid", from_attributes=True)
|
|
32
|
+
|
|
33
|
+
pattern_id: UUID = Field(
|
|
34
|
+
...,
|
|
35
|
+
description="Pattern UUID identifier from injection system",
|
|
36
|
+
)
|
|
37
|
+
utilization_score: float = Field(
|
|
38
|
+
...,
|
|
39
|
+
ge=0.0,
|
|
40
|
+
le=1.0,
|
|
41
|
+
description="Pattern utilization score 0.0-1.0",
|
|
42
|
+
)
|
|
43
|
+
utilization_method: str = Field(
|
|
44
|
+
...,
|
|
45
|
+
description="Method: identifier_match, semantic, or timeout",
|
|
46
|
+
)
|