ouroboros-ai 0.2.3__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.
Potentially problematic release.
This version of ouroboros-ai might be problematic. Click here for more details.
- ouroboros/__init__.py +1 -1
- ouroboros/bigbang/__init__.py +9 -0
- ouroboros/bigbang/interview.py +16 -18
- ouroboros/bigbang/ontology.py +180 -0
- ouroboros/cli/commands/__init__.py +2 -0
- ouroboros/cli/commands/init.py +162 -97
- ouroboros/cli/commands/mcp.py +161 -0
- ouroboros/cli/commands/run.py +165 -27
- ouroboros/cli/main.py +2 -1
- ouroboros/core/ontology_aspect.py +455 -0
- ouroboros/core/ontology_questions.py +462 -0
- ouroboros/evaluation/__init__.py +16 -1
- ouroboros/evaluation/consensus.py +569 -11
- ouroboros/evaluation/models.py +81 -0
- ouroboros/events/ontology.py +135 -0
- ouroboros/mcp/__init__.py +83 -0
- ouroboros/mcp/client/__init__.py +20 -0
- ouroboros/mcp/client/adapter.py +632 -0
- ouroboros/mcp/client/manager.py +600 -0
- ouroboros/mcp/client/protocol.py +161 -0
- ouroboros/mcp/errors.py +377 -0
- ouroboros/mcp/resources/__init__.py +22 -0
- ouroboros/mcp/resources/handlers.py +328 -0
- ouroboros/mcp/server/__init__.py +21 -0
- ouroboros/mcp/server/adapter.py +408 -0
- ouroboros/mcp/server/protocol.py +291 -0
- ouroboros/mcp/server/security.py +636 -0
- ouroboros/mcp/tools/__init__.py +24 -0
- ouroboros/mcp/tools/definitions.py +351 -0
- ouroboros/mcp/tools/registry.py +269 -0
- ouroboros/mcp/types.py +333 -0
- ouroboros/orchestrator/__init__.py +31 -0
- ouroboros/orchestrator/events.py +40 -0
- ouroboros/orchestrator/mcp_config.py +419 -0
- ouroboros/orchestrator/mcp_tools.py +483 -0
- ouroboros/orchestrator/runner.py +119 -2
- ouroboros/providers/claude_code_adapter.py +75 -0
- ouroboros/strategies/__init__.py +23 -0
- ouroboros/strategies/devil_advocate.py +197 -0
- {ouroboros_ai-0.2.3.dist-info → ouroboros_ai-0.4.0.dist-info}/METADATA +73 -17
- {ouroboros_ai-0.2.3.dist-info → ouroboros_ai-0.4.0.dist-info}/RECORD +44 -19
- {ouroboros_ai-0.2.3.dist-info → ouroboros_ai-0.4.0.dist-info}/WHEEL +0 -0
- {ouroboros_ai-0.2.3.dist-info → ouroboros_ai-0.4.0.dist-info}/entry_points.txt +0 -0
- {ouroboros_ai-0.2.3.dist-info → ouroboros_ai-0.4.0.dist-info}/licenses/LICENSE +0 -0
ouroboros/evaluation/models.py
CHANGED
|
@@ -9,7 +9,9 @@ Classes:
|
|
|
9
9
|
MechanicalResult: Aggregated Stage 1 results
|
|
10
10
|
SemanticResult: Stage 2 LLM evaluation results
|
|
11
11
|
Vote: Single model vote in consensus
|
|
12
|
+
VoterRole: Role in deliberative consensus
|
|
12
13
|
ConsensusResult: Aggregated Stage 3 results
|
|
14
|
+
DeliberationResult: Aggregated Stage 3 deliberative results
|
|
13
15
|
EvaluationContext: Input context for evaluation
|
|
14
16
|
EvaluationResult: Complete pipeline output
|
|
15
17
|
"""
|
|
@@ -21,6 +23,20 @@ from typing import Any
|
|
|
21
23
|
from ouroboros.events.base import BaseEvent
|
|
22
24
|
|
|
23
25
|
|
|
26
|
+
class VoterRole(StrEnum):
|
|
27
|
+
"""Roles in deliberative consensus.
|
|
28
|
+
|
|
29
|
+
Each role has a specific perspective in the 2-round deliberation:
|
|
30
|
+
- ADVOCATE: Argues in favor, finds strengths
|
|
31
|
+
- DEVIL: Critical perspective using ontological questions
|
|
32
|
+
- JUDGE: Weighs both sides, makes final decision
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
ADVOCATE = "advocate"
|
|
36
|
+
DEVIL = "devil"
|
|
37
|
+
JUDGE = "judge"
|
|
38
|
+
|
|
39
|
+
|
|
24
40
|
class CheckType(StrEnum):
|
|
25
41
|
"""Types of mechanical checks in Stage 1.
|
|
26
42
|
|
|
@@ -120,12 +136,14 @@ class Vote:
|
|
|
120
136
|
approved: Whether the model approves the output
|
|
121
137
|
confidence: Model's confidence in its decision (0.0-1.0)
|
|
122
138
|
reasoning: Explanation of the vote
|
|
139
|
+
role: Role in deliberative consensus (optional, for deliberative mode)
|
|
123
140
|
"""
|
|
124
141
|
|
|
125
142
|
model: str
|
|
126
143
|
approved: bool
|
|
127
144
|
confidence: float
|
|
128
145
|
reasoning: str
|
|
146
|
+
role: VoterRole | None = None
|
|
129
147
|
|
|
130
148
|
def __post_init__(self) -> None:
|
|
131
149
|
"""Validate confidence range."""
|
|
@@ -163,6 +181,69 @@ class ConsensusResult:
|
|
|
163
181
|
return len(self.votes)
|
|
164
182
|
|
|
165
183
|
|
|
184
|
+
class FinalVerdict(StrEnum):
|
|
185
|
+
"""Final verdict from Judge in deliberative consensus."""
|
|
186
|
+
|
|
187
|
+
APPROVED = "approved"
|
|
188
|
+
REJECTED = "rejected"
|
|
189
|
+
CONDITIONAL = "conditional"
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
@dataclass(frozen=True, slots=True)
|
|
193
|
+
class JudgmentResult:
|
|
194
|
+
"""Result from the Judge in deliberative consensus.
|
|
195
|
+
|
|
196
|
+
Attributes:
|
|
197
|
+
verdict: Final decision (approved/rejected/conditional)
|
|
198
|
+
confidence: Judge's confidence in decision (0.0-1.0)
|
|
199
|
+
reasoning: Explanation of the judgment
|
|
200
|
+
conditions: Conditions for approval (if conditional)
|
|
201
|
+
"""
|
|
202
|
+
|
|
203
|
+
verdict: FinalVerdict
|
|
204
|
+
confidence: float
|
|
205
|
+
reasoning: str
|
|
206
|
+
conditions: tuple[str, ...] | None = None
|
|
207
|
+
|
|
208
|
+
def __post_init__(self) -> None:
|
|
209
|
+
"""Validate confidence range."""
|
|
210
|
+
if not 0.0 <= self.confidence <= 1.0:
|
|
211
|
+
msg = f"confidence must be between 0.0 and 1.0, got {self.confidence}"
|
|
212
|
+
raise ValueError(msg)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
@dataclass(frozen=True, slots=True)
|
|
216
|
+
class DeliberationResult:
|
|
217
|
+
"""Result of 2-round deliberative consensus.
|
|
218
|
+
|
|
219
|
+
Round 1: Advocate and Devil's Advocate present positions
|
|
220
|
+
Round 2: Judge reviews both and makes final decision
|
|
221
|
+
|
|
222
|
+
Attributes:
|
|
223
|
+
final_verdict: The Judge's final decision
|
|
224
|
+
advocate_position: The Advocate's vote and reasoning
|
|
225
|
+
devil_position: The Devil's Advocate vote and reasoning
|
|
226
|
+
judgment: The Judge's full judgment
|
|
227
|
+
is_root_solution: Whether Devil confirmed this addresses root cause
|
|
228
|
+
"""
|
|
229
|
+
|
|
230
|
+
final_verdict: FinalVerdict
|
|
231
|
+
advocate_position: Vote
|
|
232
|
+
devil_position: Vote
|
|
233
|
+
judgment: JudgmentResult
|
|
234
|
+
is_root_solution: bool
|
|
235
|
+
|
|
236
|
+
@property
|
|
237
|
+
def approved(self) -> bool:
|
|
238
|
+
"""Whether the final verdict is approval."""
|
|
239
|
+
return self.final_verdict == FinalVerdict.APPROVED
|
|
240
|
+
|
|
241
|
+
@property
|
|
242
|
+
def has_conditions(self) -> bool:
|
|
243
|
+
"""Whether approval is conditional."""
|
|
244
|
+
return self.final_verdict == FinalVerdict.CONDITIONAL
|
|
245
|
+
|
|
246
|
+
|
|
166
247
|
@dataclass(frozen=True, slots=True)
|
|
167
248
|
class EvaluationContext:
|
|
168
249
|
"""Input context for the evaluation pipeline.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""Ontological Analysis Events.
|
|
2
|
+
|
|
3
|
+
Events emitted during ontological analysis across phases.
|
|
4
|
+
These events support observability and audit trails for
|
|
5
|
+
the AOP-based ontological framework.
|
|
6
|
+
|
|
7
|
+
Event Types:
|
|
8
|
+
- ontology.analysis.passed: Analysis passed, execution continues
|
|
9
|
+
- ontology.analysis.violated: Analysis failed, execution may halt
|
|
10
|
+
|
|
11
|
+
Reference: docs/ontological-framework/aop-design.md
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from datetime import UTC, datetime
|
|
15
|
+
from typing import Any
|
|
16
|
+
from uuid import uuid4
|
|
17
|
+
|
|
18
|
+
from pydantic import Field
|
|
19
|
+
|
|
20
|
+
from ouroboros.core.ontology_aspect import OntologicalJoinPoint
|
|
21
|
+
from ouroboros.events.base import BaseEvent
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class OntologicalAnalysisEvent(BaseEvent):
|
|
25
|
+
"""Base event for ontological analysis.
|
|
26
|
+
|
|
27
|
+
Common fields for all ontology-related events.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
join_point: OntologicalJoinPoint
|
|
31
|
+
"""Which phase triggered this event."""
|
|
32
|
+
|
|
33
|
+
confidence: float = 0.0
|
|
34
|
+
"""Analysis confidence (0.0-1.0)."""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class OntologicalPassedEvent(OntologicalAnalysisEvent):
|
|
38
|
+
"""Emitted when ontological analysis passes.
|
|
39
|
+
|
|
40
|
+
The subject passed ontological scrutiny and execution continues.
|
|
41
|
+
|
|
42
|
+
Event Type: ontology.analysis.passed
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
type: str = "ontology.analysis.passed"
|
|
46
|
+
aggregate_type: str = "ontology"
|
|
47
|
+
aggregate_id: str = Field(default_factory=lambda: str(uuid4()))
|
|
48
|
+
|
|
49
|
+
def __init__(
|
|
50
|
+
self,
|
|
51
|
+
*,
|
|
52
|
+
join_point: OntologicalJoinPoint,
|
|
53
|
+
confidence: float = 1.0,
|
|
54
|
+
**kwargs: Any,
|
|
55
|
+
) -> None:
|
|
56
|
+
"""Initialize passed event.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
join_point: Which phase triggered this event.
|
|
60
|
+
confidence: Analysis confidence.
|
|
61
|
+
**kwargs: Additional BaseEvent fields.
|
|
62
|
+
"""
|
|
63
|
+
super().__init__(
|
|
64
|
+
join_point=join_point,
|
|
65
|
+
confidence=confidence,
|
|
66
|
+
data={
|
|
67
|
+
"join_point": join_point.value,
|
|
68
|
+
"confidence": confidence,
|
|
69
|
+
"outcome": "passed",
|
|
70
|
+
},
|
|
71
|
+
**kwargs,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class OntologicalViolationEvent(OntologicalAnalysisEvent):
|
|
76
|
+
"""Emitted when ontological analysis fails.
|
|
77
|
+
|
|
78
|
+
The subject failed ontological scrutiny. Execution may halt
|
|
79
|
+
depending on aspect configuration.
|
|
80
|
+
|
|
81
|
+
Event Type: ontology.analysis.violated
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
type: str = "ontology.analysis.violated"
|
|
85
|
+
aggregate_type: str = "ontology"
|
|
86
|
+
aggregate_id: str = Field(default_factory=lambda: str(uuid4()))
|
|
87
|
+
|
|
88
|
+
reasoning: tuple[str, ...] = ()
|
|
89
|
+
"""Why the analysis failed."""
|
|
90
|
+
|
|
91
|
+
suggestions: tuple[str, ...] = ()
|
|
92
|
+
"""Refinement suggestions."""
|
|
93
|
+
|
|
94
|
+
def __init__(
|
|
95
|
+
self,
|
|
96
|
+
*,
|
|
97
|
+
join_point: OntologicalJoinPoint,
|
|
98
|
+
confidence: float = 0.8,
|
|
99
|
+
reasoning: tuple[str, ...] | list[str] = (),
|
|
100
|
+
suggestions: tuple[str, ...] | list[str] = (),
|
|
101
|
+
**kwargs: Any,
|
|
102
|
+
) -> None:
|
|
103
|
+
"""Initialize violation event.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
join_point: Which phase triggered this event.
|
|
107
|
+
confidence: Analysis confidence.
|
|
108
|
+
reasoning: Why the analysis failed.
|
|
109
|
+
suggestions: Refinement suggestions.
|
|
110
|
+
**kwargs: Additional BaseEvent fields.
|
|
111
|
+
"""
|
|
112
|
+
reasoning_tuple = tuple(reasoning) if isinstance(reasoning, list) else reasoning
|
|
113
|
+
suggestions_tuple = tuple(suggestions) if isinstance(suggestions, list) else suggestions
|
|
114
|
+
|
|
115
|
+
super().__init__(
|
|
116
|
+
join_point=join_point,
|
|
117
|
+
confidence=confidence,
|
|
118
|
+
reasoning=reasoning_tuple,
|
|
119
|
+
suggestions=suggestions_tuple,
|
|
120
|
+
data={
|
|
121
|
+
"join_point": join_point.value,
|
|
122
|
+
"confidence": confidence,
|
|
123
|
+
"outcome": "violated",
|
|
124
|
+
"reasoning": reasoning_tuple,
|
|
125
|
+
"suggestions": suggestions_tuple,
|
|
126
|
+
},
|
|
127
|
+
**kwargs,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
__all__ = [
|
|
132
|
+
"OntologicalAnalysisEvent",
|
|
133
|
+
"OntologicalPassedEvent",
|
|
134
|
+
"OntologicalViolationEvent",
|
|
135
|
+
]
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""MCP (Model Context Protocol) integration for Ouroboros.
|
|
2
|
+
|
|
3
|
+
This module provides both MCP client and server functionality:
|
|
4
|
+
- MCP Client: Connect to external MCP servers to use their tools and resources
|
|
5
|
+
- MCP Server: Expose Ouroboros functionality as an MCP server
|
|
6
|
+
|
|
7
|
+
Public API:
|
|
8
|
+
Errors:
|
|
9
|
+
MCPError, MCPClientError, MCPServerError, MCPAuthError,
|
|
10
|
+
MCPTimeoutError, MCPConnectionError, MCPProtocolError,
|
|
11
|
+
MCPResourceNotFoundError, MCPToolError
|
|
12
|
+
|
|
13
|
+
Types:
|
|
14
|
+
TransportType, MCPServerConfig, MCPToolDefinition, MCPToolResult,
|
|
15
|
+
MCPToolParameter, MCPContentItem, ContentType,
|
|
16
|
+
MCPResourceDefinition, MCPResourceContent,
|
|
17
|
+
MCPPromptDefinition, MCPPromptArgument,
|
|
18
|
+
MCPCapabilities, MCPServerInfo, MCPRequest, MCPResponse
|
|
19
|
+
|
|
20
|
+
Client:
|
|
21
|
+
MCPClient (Protocol), MCPClientAdapter, MCPClientManager
|
|
22
|
+
|
|
23
|
+
Server:
|
|
24
|
+
MCPServer (Protocol), MCPServerAdapter
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
from ouroboros.mcp.errors import (
|
|
28
|
+
MCPAuthError,
|
|
29
|
+
MCPClientError,
|
|
30
|
+
MCPConnectionError,
|
|
31
|
+
MCPError,
|
|
32
|
+
MCPProtocolError,
|
|
33
|
+
MCPResourceNotFoundError,
|
|
34
|
+
MCPServerError,
|
|
35
|
+
MCPTimeoutError,
|
|
36
|
+
MCPToolError,
|
|
37
|
+
)
|
|
38
|
+
from ouroboros.mcp.types import (
|
|
39
|
+
ContentType,
|
|
40
|
+
MCPCapabilities,
|
|
41
|
+
MCPContentItem,
|
|
42
|
+
MCPPromptArgument,
|
|
43
|
+
MCPPromptDefinition,
|
|
44
|
+
MCPRequest,
|
|
45
|
+
MCPResourceContent,
|
|
46
|
+
MCPResourceDefinition,
|
|
47
|
+
MCPResponse,
|
|
48
|
+
MCPServerConfig,
|
|
49
|
+
MCPServerInfo,
|
|
50
|
+
MCPToolDefinition,
|
|
51
|
+
MCPToolParameter,
|
|
52
|
+
MCPToolResult,
|
|
53
|
+
TransportType,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
__all__ = [
|
|
57
|
+
# Errors
|
|
58
|
+
"MCPError",
|
|
59
|
+
"MCPClientError",
|
|
60
|
+
"MCPServerError",
|
|
61
|
+
"MCPAuthError",
|
|
62
|
+
"MCPTimeoutError",
|
|
63
|
+
"MCPConnectionError",
|
|
64
|
+
"MCPProtocolError",
|
|
65
|
+
"MCPResourceNotFoundError",
|
|
66
|
+
"MCPToolError",
|
|
67
|
+
# Types
|
|
68
|
+
"TransportType",
|
|
69
|
+
"ContentType",
|
|
70
|
+
"MCPServerConfig",
|
|
71
|
+
"MCPToolDefinition",
|
|
72
|
+
"MCPToolParameter",
|
|
73
|
+
"MCPToolResult",
|
|
74
|
+
"MCPContentItem",
|
|
75
|
+
"MCPResourceDefinition",
|
|
76
|
+
"MCPResourceContent",
|
|
77
|
+
"MCPPromptDefinition",
|
|
78
|
+
"MCPPromptArgument",
|
|
79
|
+
"MCPCapabilities",
|
|
80
|
+
"MCPServerInfo",
|
|
81
|
+
"MCPRequest",
|
|
82
|
+
"MCPResponse",
|
|
83
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""MCP Client package.
|
|
2
|
+
|
|
3
|
+
This package provides MCP client functionality for connecting to external
|
|
4
|
+
MCP servers and using their tools, resources, and prompts.
|
|
5
|
+
|
|
6
|
+
Public API:
|
|
7
|
+
MCPClient: Protocol defining the client interface
|
|
8
|
+
MCPClientAdapter: Concrete implementation using the MCP SDK
|
|
9
|
+
MCPClientManager: Manager for multiple server connections
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from ouroboros.mcp.client.adapter import MCPClientAdapter
|
|
13
|
+
from ouroboros.mcp.client.manager import MCPClientManager
|
|
14
|
+
from ouroboros.mcp.client.protocol import MCPClient
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"MCPClient",
|
|
18
|
+
"MCPClientAdapter",
|
|
19
|
+
"MCPClientManager",
|
|
20
|
+
]
|