agent_hypervisor 3.1.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.
Files changed (60) hide show
  1. agent_hypervisor-3.1.0.dist-info/METADATA +824 -0
  2. agent_hypervisor-3.1.0.dist-info/RECORD +60 -0
  3. agent_hypervisor-3.1.0.dist-info/WHEEL +4 -0
  4. agent_hypervisor-3.1.0.dist-info/entry_points.txt +2 -0
  5. agent_hypervisor-3.1.0.dist-info/licenses/LICENSE +21 -0
  6. hypervisor/__init__.py +160 -0
  7. hypervisor/api/__init__.py +7 -0
  8. hypervisor/api/models.py +285 -0
  9. hypervisor/api/server.py +742 -0
  10. hypervisor/audit/__init__.py +4 -0
  11. hypervisor/audit/commitment.py +76 -0
  12. hypervisor/audit/delta.py +135 -0
  13. hypervisor/audit/gc.py +99 -0
  14. hypervisor/cli/__init__.py +3 -0
  15. hypervisor/cli/formatters.py +99 -0
  16. hypervisor/cli/session_commands.py +200 -0
  17. hypervisor/constants.py +106 -0
  18. hypervisor/core.py +352 -0
  19. hypervisor/integrations/__init__.py +10 -0
  20. hypervisor/integrations/iatp_adapter.py +142 -0
  21. hypervisor/integrations/nexus_adapter.py +108 -0
  22. hypervisor/integrations/verification_adapter.py +122 -0
  23. hypervisor/liability/__init__.py +142 -0
  24. hypervisor/liability/attribution.py +86 -0
  25. hypervisor/liability/ledger.py +121 -0
  26. hypervisor/liability/quarantine.py +119 -0
  27. hypervisor/liability/slashing.py +80 -0
  28. hypervisor/liability/vouching.py +134 -0
  29. hypervisor/models.py +277 -0
  30. hypervisor/observability/__init__.py +27 -0
  31. hypervisor/observability/causal_trace.py +70 -0
  32. hypervisor/observability/event_bus.py +222 -0
  33. hypervisor/observability/prometheus_collector.py +248 -0
  34. hypervisor/observability/saga_span_exporter.py +341 -0
  35. hypervisor/providers.py +121 -0
  36. hypervisor/py.typed +0 -0
  37. hypervisor/reversibility/__init__.py +3 -0
  38. hypervisor/reversibility/registry.py +108 -0
  39. hypervisor/rings/__init__.py +21 -0
  40. hypervisor/rings/breach_detector.py +200 -0
  41. hypervisor/rings/classifier.py +78 -0
  42. hypervisor/rings/elevation.py +219 -0
  43. hypervisor/rings/enforcer.py +97 -0
  44. hypervisor/saga/__init__.py +22 -0
  45. hypervisor/saga/checkpoint.py +110 -0
  46. hypervisor/saga/dsl.py +190 -0
  47. hypervisor/saga/fan_out.py +126 -0
  48. hypervisor/saga/orchestrator.py +229 -0
  49. hypervisor/saga/schema.py +244 -0
  50. hypervisor/saga/state_machine.py +157 -0
  51. hypervisor/security/__init__.py +13 -0
  52. hypervisor/security/kill_switch.py +200 -0
  53. hypervisor/security/rate_limiter.py +190 -0
  54. hypervisor/session/__init__.py +194 -0
  55. hypervisor/session/intent_locks.py +118 -0
  56. hypervisor/session/isolation.py +37 -0
  57. hypervisor/session/sso.py +169 -0
  58. hypervisor/session/vector_clock.py +118 -0
  59. hypervisor/verification/__init__.py +3 -0
  60. hypervisor/verification/history.py +173 -0
@@ -0,0 +1,60 @@
1
+ hypervisor/__init__.py,sha256=XaycXw_46Ct306g7MIB8Ow3kp0F5NfY9qJGnPBrMvds,4516
2
+ hypervisor/constants.py,sha256=UQ8c1E4dVPOlVeXwXd6CKkNx_3tYvg_x2RDIl--hqV8,4187
3
+ hypervisor/core.py,sha256=ZrBivTP2rLGxp0RvIF0sRHnO-BdKYKsjdgwkMTZXSkQ,12868
4
+ hypervisor/models.py,sha256=eUU5_sYIqW52nCCxbeMCE2y6akFudNJOCnjI8n0DG84,10009
5
+ hypervisor/providers.py,sha256=bGArL0UdCGm0OF2mS1TL5QmUGVsvgcqtJzF-7iJJ7kg,3822
6
+ hypervisor/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ hypervisor/api/__init__.py,sha256=mQJ-e_7REaXDKn8PPgKFzxvCv3R-oPYoauj4vYMs5QQ,180
8
+ hypervisor/api/models.py,sha256=RtWB3fLzDiRiD0xvd6i7X9RJF959VmJys9WaDZ6d5WI,7818
9
+ hypervisor/api/server.py,sha256=tudVp2hjxD_eprE_MZ7pVVxASShrlmNdRORkjeHYUVc,26657
10
+ hypervisor/audit/__init__.py,sha256=d4Gi_4wedGGQDvrpd8tKs7fvr3YtVOzqR2noWx7B81Q,176
11
+ hypervisor/audit/commitment.py,sha256=8bWQDnINQReG3O1psy3Eowpr_n9Kqh8FvfRdBXPqTWc,2235
12
+ hypervisor/audit/delta.py,sha256=Ib5Ivy84YtTUB8Y7zKfl3hb9yZJywsePuds6S_Mbj60,4130
13
+ hypervisor/audit/gc.py,sha256=-GuZmGORS7EwzJKbEMt7_--bTQqp3ci_pTus9UrV-R0,2898
14
+ hypervisor/cli/__init__.py,sha256=PmQyHhvPOKtpk6ILlhtvdJTWUfFYon3Y6uJzD9hJ37A,124
15
+ hypervisor/cli/formatters.py,sha256=2PKV8PxvC8hmWpVGqs3IdUud03Ll_YuH1YrRT-IMn2k,3271
16
+ hypervisor/cli/session_commands.py,sha256=-f5_yg9paMNXXOtC_Z6ydfdhtTjDI6zliFYqCfhgmc0,6089
17
+ hypervisor/integrations/__init__.py,sha256=5-co8S88Ma7RWSzXGxhVX67t1mcmuqqNg5-a9FbHSdI,353
18
+ hypervisor/integrations/iatp_adapter.py,sha256=yGFOpqiaDNDw0E-PovfXSBGoT9dR0LapziKeXTPLDG8,5306
19
+ hypervisor/integrations/nexus_adapter.py,sha256=Y-F8WHZzjPvdxHbnZAZeJypr0fzqOUecferfYkivgXY,3014
20
+ hypervisor/integrations/verification_adapter.py,sha256=c5YEZ5oheMlEvMyOY7WGPIEVzSbovdrnnVewVdVwRWI,3643
21
+ hypervisor/liability/__init__.py,sha256=4hWzz0dqji4aJgUjXogOaSepGe8oN1gvxTbW5U8HTyo,4462
22
+ hypervisor/liability/attribution.py,sha256=boofYSZbkK0FMlU_uxr9T7wUO5AIIVijQZaVRjCC09s,2693
23
+ hypervisor/liability/ledger.py,sha256=0qNmxD0wzzEH85cYoBOGG4puu1QmKa3ukruO9gPezMI,3510
24
+ hypervisor/liability/quarantine.py,sha256=Vb6EMTe3OBvhNAx089lIpzOfUNbhU9hkZW7MvrVDXUg,3491
25
+ hypervisor/liability/slashing.py,sha256=xuBZ81GYIw7tGyztXWzdu_rZyJBBqcY6lK-JQr6foUE,2028
26
+ hypervisor/liability/vouching.py,sha256=VTKlTg2Q6RuccX_Zu45WwobzeezvZyS8KaIgiKrveMY,4067
27
+ hypervisor/observability/__init__.py,sha256=PBCcIE2Oxwq9R9lUuHlyxHpF1ViFQ9Fp3dVrrIk7s6w,718
28
+ hypervisor/observability/causal_trace.py,sha256=w6GOY_E119PkzTFghqQCw9iFrjmweFWmkml9HJnWH40,2295
29
+ hypervisor/observability/event_bus.py,sha256=6ysWj8O7KIhfbrnr09u472OZJnwle_wG-oOvIJ7QzkE,7438
30
+ hypervisor/observability/prometheus_collector.py,sha256=q8OCzYioH57P1_DPL-mHcfPiqM5pTYFHit4Ues8sjgg,9442
31
+ hypervisor/observability/saga_span_exporter.py,sha256=cWjMbZx2MQjr5UZS_KqCNgoPFnWV-ty8JPYaMfyjOrU,11754
32
+ hypervisor/reversibility/__init__.py,sha256=pXGNeoNLlgq-KKIlcERgQ7X0KB5gjiplHUAF7e_Wa2A,105
33
+ hypervisor/reversibility/registry.py,sha256=Qx6rfUuz39gCRQm_yu811uYEntvcgJasLp_7Rqb8L8U,3602
34
+ hypervisor/rings/__init__.py,sha256=uLAUcJUVHhisBEix-iepL0bTY7sgTjW45mdro87dFkA,587
35
+ hypervisor/rings/breach_detector.py,sha256=butsp2_GizMTEZNPtiKtnTqipqUUSr8WD3M5gbs1B8M,6865
36
+ hypervisor/rings/classifier.py,sha256=50C83kS86lHzwNMvUjlyweHfTFX1k3P9WmK31oa4vMI,2516
37
+ hypervisor/rings/elevation.py,sha256=rXvTeEboTg4rzCHrZnOubvms5PaUR94mKCK3KTGboSc,7386
38
+ hypervisor/rings/enforcer.py,sha256=4QqtHWIwaS4B7IuFU-xP6DjqjkOKwmLewSBWvS789p0,3077
39
+ hypervisor/saga/__init__.py,sha256=tv5A_SPMqAu5LZi29UfKPBTe6rkP4IyRguGeMEH6d-k,747
40
+ hypervisor/saga/checkpoint.py,sha256=xntQ-OYK_BP1k7zEpwfUjNhhV_FnyC8maH8mxXEjQVk,3324
41
+ hypervisor/saga/dsl.py,sha256=3fWUdWaYR51X3KfR7yYGPGGbGi3ONxmID5RrhVtZ5SA,6287
42
+ hypervisor/saga/fan_out.py,sha256=ddV3gHAbHmTXgXtGPPkzJNV8GhZgom5eaw9zhXkMgCo,4359
43
+ hypervisor/saga/orchestrator.py,sha256=XN_-SCTg6WwYuQPjT4Dcz3UtFu9kdTP6IgDPAsDW17w,7415
44
+ hypervisor/saga/schema.py,sha256=5_c5uhv-k6w1Jq-YAv3WJ5UnwV97dtFacI1ytmHFZD4,7973
45
+ hypervisor/saga/state_machine.py,sha256=coscEM-rnqj7Tqmj1riyrquGJg4DcHzotLIGB7BRO7c,5025
46
+ hypervisor/security/__init__.py,sha256=Y-0p_uteRbQ9pVmt2lxH3XXCva2Ce5wCGfvwX32TmSM,398
47
+ hypervisor/security/kill_switch.py,sha256=n8gd203HHkjKUVS6sLWch1N9TBfIqGtlvAVdU0gd0Xw,6520
48
+ hypervisor/security/rate_limiter.py,sha256=ZwVzwMzBZ0wIo544wJ4RGil7fkkph5xpUyjTjQnTDMc,5774
49
+ hypervisor/session/__init__.py,sha256=sYuk7V4foGZMVbKwY9SVyTlxZ27mnwMAw53UlguEIaY,7031
50
+ hypervisor/session/intent_locks.py,sha256=MhJTI79_3nMhQg6bad85M0H2rH1Ivv4Oqr3palEJgpc,3332
51
+ hypervisor/session/isolation.py,sha256=vI3pqw3zzHqfSTqz3m6agMpoan2qoEcPIGemNelDF60,887
52
+ hypervisor/session/sso.py,sha256=eaOgfSdj1fvjCdBCbt0302ZuChjWVJX2_F7c1wp-VXc,6027
53
+ hypervisor/session/vector_clock.py,sha256=tde5eAMZff737MX9rBivbGII1uuiNpwMr9zCSFa57Rg,3920
54
+ hypervisor/verification/__init__.py,sha256=OOD30e_3b0uzCEBt1JJ2AGXq64PM0ORRzjZYBF9zI2A,104
55
+ hypervisor/verification/history.py,sha256=8DDnm5-cRBqvH_5r6v5OKbmU4rKwGy2JEeoN62q1FhA,5898
56
+ agent_hypervisor-3.1.0.dist-info/METADATA,sha256=NhiNdY8wEeHpaFSdMNkEDJ0k8v_t9Q9XQXPIJ05Q3K0,32028
57
+ agent_hypervisor-3.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
58
+ agent_hypervisor-3.1.0.dist-info/entry_points.txt,sha256=I9hsjWJjzQWhKsrLdOe_tWwBZkx3VyxOlbncTZIcQiE,68
59
+ agent_hypervisor-3.1.0.dist-info/licenses/LICENSE,sha256=ffINzfkZfplFwUhY1Bxg8RtSuT5baeK2NBa4dNWY0yI,1074
60
+ agent_hypervisor-3.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ hypervisor = hypervisor.cli.session_commands:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
hypervisor/__init__.py ADDED
@@ -0,0 +1,160 @@
1
+ # Copyright (c) Microsoft Corporation.
2
+ # Licensed under the MIT License.
3
+ """
4
+ Agent Hypervisor v2.0
5
+
6
+ Runtime supervisor for multi-agent Shared Sessions with execution rings,
7
+ liability tracking, saga orchestration, and audit trails.
8
+
9
+ Usage:
10
+ >>> from hypervisor import Hypervisor, SessionConfig, ConsistencyMode
11
+ >>> hv = Hypervisor()
12
+ >>> session = await hv.create_session(
13
+ ... config=SessionConfig(consistency_mode=ConsistencyMode.EVENTUAL)
14
+ ... )
15
+
16
+ Version: 2.0.0
17
+ """
18
+
19
+ __version__ = "3.1.0"
20
+
21
+ # Centralized constants
22
+ from hypervisor import constants # noqa: F401
23
+
24
+ # Core models
25
+ from hypervisor.audit.commitment import CommitmentEngine
26
+
27
+ # Audit
28
+ from hypervisor.audit.delta import DeltaEngine
29
+ from hypervisor.audit.gc import EphemeralGC
30
+
31
+ # Top-level orchestrator
32
+ from hypervisor.core import Hypervisor
33
+ from hypervisor.liability import LiabilityMatrix
34
+ from hypervisor.liability.attribution import AttributionResult, CausalAttributor
35
+ from hypervisor.liability.ledger import LedgerEntryType, LiabilityLedger
36
+ from hypervisor.liability.quarantine import QuarantineManager, QuarantineReason
37
+ from hypervisor.liability.slashing import SlashingEngine
38
+
39
+ # Liability engine
40
+ from hypervisor.liability.vouching import VouchingEngine, VouchRecord
41
+ from hypervisor.models import (
42
+ ConsistencyMode,
43
+ ExecutionRing,
44
+ ReversibilityLevel,
45
+ SessionConfig,
46
+ SessionState,
47
+ )
48
+ from hypervisor.observability.causal_trace import CausalTraceId
49
+
50
+ # Observability
51
+ from hypervisor.observability.event_bus import EventType, HypervisorEvent, HypervisorEventBus
52
+
53
+ # Reversibility
54
+ from hypervisor.reversibility.registry import ReversibilityRegistry
55
+ from hypervisor.rings.breach_detector import BreachSeverity, RingBreachDetector
56
+ from hypervisor.rings.classifier import ActionClassifier
57
+ from hypervisor.rings.elevation import ElevationDenialReason, RingElevation, RingElevationManager
58
+
59
+ # Execution rings
60
+ from hypervisor.rings.enforcer import RingEnforcer
61
+ from hypervisor.saga.checkpoint import CheckpointManager, SemanticCheckpoint
62
+ from hypervisor.saga.dsl import SagaDefinition, SagaDSLParser
63
+ from hypervisor.saga.fan_out import FanOutOrchestrator, FanOutPolicy
64
+
65
+ # Saga
66
+ from hypervisor.saga.orchestrator import SagaOrchestrator, SagaTimeoutError
67
+ from hypervisor.saga.state_machine import SagaState, StepState
68
+ from hypervisor.security.kill_switch import KillResult, KillSwitch
69
+
70
+ # Security
71
+ from hypervisor.security.rate_limiter import AgentRateLimiter, RateLimitExceeded
72
+
73
+ # Session management
74
+ from hypervisor.session import SharedSessionObject
75
+ from hypervisor.session.intent_locks import (
76
+ DeadlockError,
77
+ IntentLockManager,
78
+ LockContentionError,
79
+ LockIntent,
80
+ )
81
+ from hypervisor.session.isolation import IsolationLevel
82
+ from hypervisor.session.sso import SessionVFS, VFSEdit, VFSPermissionError
83
+ from hypervisor.session.vector_clock import CausalViolationError, VectorClock, VectorClockManager
84
+
85
+ # Verification
86
+ from hypervisor.verification.history import TransactionHistoryVerifier
87
+
88
+ __all__ = [
89
+ # Version
90
+ "__version__",
91
+ # Core
92
+ "Hypervisor",
93
+ # Models
94
+ "ConsistencyMode",
95
+ "ExecutionRing",
96
+ "ReversibilityLevel",
97
+ "SessionConfig",
98
+ "SessionState",
99
+ # Session
100
+ "SharedSessionObject",
101
+ "SessionVFS",
102
+ "VFSEdit",
103
+ "VFSPermissionError",
104
+ "VectorClock",
105
+ "VectorClockManager",
106
+ "CausalViolationError",
107
+ "IntentLockManager",
108
+ "LockIntent",
109
+ "LockContentionError",
110
+ "DeadlockError",
111
+ "IsolationLevel",
112
+ # Liability
113
+ "VouchRecord",
114
+ "VouchingEngine",
115
+ "SlashingEngine",
116
+ "LiabilityMatrix",
117
+ "CausalAttributor",
118
+ "AttributionResult",
119
+ "QuarantineManager",
120
+ "QuarantineReason",
121
+ "LiabilityLedger",
122
+ "LedgerEntryType",
123
+ # Rings
124
+ "RingEnforcer",
125
+ "ActionClassifier",
126
+ "RingElevationManager",
127
+ "RingElevation",
128
+ "ElevationDenialReason",
129
+ "RingBreachDetector",
130
+ "BreachSeverity",
131
+ # Reversibility
132
+ "ReversibilityRegistry",
133
+ # Saga
134
+ "SagaOrchestrator",
135
+ "SagaTimeoutError",
136
+ "SagaState",
137
+ "StepState",
138
+ "FanOutOrchestrator",
139
+ "FanOutPolicy",
140
+ "CheckpointManager",
141
+ "SemanticCheckpoint",
142
+ "SagaDSLParser",
143
+ "SagaDefinition",
144
+ # Audit
145
+ "DeltaEngine",
146
+ "CommitmentEngine",
147
+ "EphemeralGC",
148
+ # Verification
149
+ "TransactionHistoryVerifier",
150
+ # Observability
151
+ "HypervisorEventBus",
152
+ "EventType",
153
+ "HypervisorEvent",
154
+ "CausalTraceId",
155
+ # Security
156
+ "AgentRateLimiter",
157
+ "RateLimitExceeded",
158
+ "KillSwitch",
159
+ "KillResult",
160
+ ]
@@ -0,0 +1,7 @@
1
+ # Copyright (c) Microsoft Corporation.
2
+ # Licensed under the MIT License.
3
+ """Hypervisor REST API package."""
4
+
5
+ from hypervisor.api.server import create_app
6
+
7
+ __all__ = ["create_app"]
@@ -0,0 +1,285 @@
1
+ # Copyright (c) Microsoft Corporation.
2
+ # Licensed under the MIT License.
3
+ """Pydantic request/response models for the Hypervisor REST API."""
4
+
5
+ from __future__ import annotations
6
+
7
+ from datetime import datetime
8
+ from typing import Any
9
+
10
+ from pydantic import BaseModel, Field
11
+
12
+ from hypervisor.models import ConsistencyMode
13
+
14
+ # ── Session models ──────────────────────────────────────────────────────────
15
+
16
+ class CreateSessionRequest(BaseModel):
17
+ """Request body for creating a new session."""
18
+
19
+ creator_did: str = Field(..., description="DID of the session creator")
20
+ consistency_mode: ConsistencyMode = ConsistencyMode.EVENTUAL
21
+ max_participants: int = 10
22
+ max_duration_seconds: int = 3600
23
+ min_eff_score: float = 0.60
24
+ enable_audit: bool = True
25
+ enable_blockchain_commitment: bool = False
26
+
27
+
28
+ class ParticipantInfo(BaseModel):
29
+ """Serialized session participant."""
30
+
31
+ agent_did: str
32
+ ring: int
33
+ sigma_raw: float
34
+ eff_score: float
35
+ joined_at: str
36
+ is_active: bool
37
+
38
+
39
+ class CreateSessionResponse(BaseModel):
40
+ """Response after creating a session."""
41
+
42
+ session_id: str
43
+ state: str
44
+ consistency_mode: str
45
+ created_at: str
46
+
47
+
48
+ class SessionDetailResponse(BaseModel):
49
+ """Detailed session information."""
50
+
51
+ session_id: str
52
+ state: str
53
+ consistency_mode: str
54
+ creator_did: str
55
+ participant_count: int
56
+ participants: list[ParticipantInfo]
57
+ created_at: str
58
+ terminated_at: str | None = None
59
+ sagas: list[dict[str, Any]] = []
60
+
61
+
62
+ class SessionListItem(BaseModel):
63
+ """Summary item for session listing."""
64
+
65
+ session_id: str
66
+ state: str
67
+ consistency_mode: str
68
+ participant_count: int
69
+ created_at: str
70
+
71
+
72
+ class JoinSessionRequest(BaseModel):
73
+ """Request body for joining a session."""
74
+
75
+ agent_did: str = Field(..., description="DID of the joining agent")
76
+ actions: list[dict[str, Any]] | None = None
77
+ sigma_raw: float = 0.0
78
+
79
+
80
+ class JoinSessionResponse(BaseModel):
81
+ """Response after joining a session."""
82
+
83
+ agent_did: str
84
+ session_id: str
85
+ assigned_ring: int
86
+ ring_name: str
87
+
88
+
89
+ # ── Ring models ─────────────────────────────────────────────────────────────
90
+
91
+ class RingDistributionResponse(BaseModel):
92
+ """Ring distribution across session participants."""
93
+
94
+ session_id: str
95
+ distribution: dict[str, list[str]]
96
+
97
+
98
+ class AgentRingResponse(BaseModel):
99
+ """Agent's current ring assignment."""
100
+
101
+ agent_did: str
102
+ ring: int
103
+ ring_name: str
104
+ session_id: str
105
+
106
+
107
+ class RingCheckRequest(BaseModel):
108
+ """Request body for checking ring-based access."""
109
+
110
+ agent_ring: int = Field(..., description="Agent's current ring level (0-3)")
111
+ action: dict[str, Any] = Field(..., description="ActionDescriptor fields")
112
+ eff_score: float = Field(..., description="Agent's effective reputation score")
113
+ has_consensus: bool = False
114
+ has_sre_witness: bool = False
115
+
116
+
117
+ class RingCheckResponse(BaseModel):
118
+ """Response from ring access check."""
119
+
120
+ allowed: bool
121
+ required_ring: int
122
+ agent_ring: int
123
+ eff_score: float
124
+ reason: str
125
+ requires_consensus: bool = False
126
+ requires_sre_witness: bool = False
127
+
128
+
129
+ # ── Saga models ─────────────────────────────────────────────────────────────
130
+
131
+ class CreateSagaResponse(BaseModel):
132
+ """Response after creating a saga."""
133
+
134
+ saga_id: str
135
+ session_id: str
136
+ state: str
137
+ created_at: str
138
+
139
+
140
+ class SagaDetailResponse(BaseModel):
141
+ """Detailed saga information."""
142
+
143
+ saga_id: str
144
+ session_id: str
145
+ state: str
146
+ created_at: str
147
+ completed_at: str | None = None
148
+ error: str | None = None
149
+ steps: list[dict[str, Any]]
150
+
151
+
152
+ class AddStepRequest(BaseModel):
153
+ """Request body for adding a step to a saga."""
154
+
155
+ action_id: str
156
+ agent_did: str
157
+ execute_api: str
158
+ undo_api: str | None = None
159
+ timeout_seconds: int = 300
160
+ max_retries: int = 0
161
+
162
+
163
+ class AddStepResponse(BaseModel):
164
+ """Response after adding a step."""
165
+
166
+ step_id: str
167
+ saga_id: str
168
+ action_id: str
169
+ state: str
170
+
171
+
172
+ class ExecuteStepResponse(BaseModel):
173
+ """Response after executing a step."""
174
+
175
+ step_id: str
176
+ saga_id: str
177
+ state: str
178
+ error: str | None = None
179
+
180
+
181
+ # ── Liability models ────────────────────────────────────────────────────────
182
+
183
+ class CreateVouchRequest(BaseModel):
184
+ """Request body for creating a sponsor."""
185
+
186
+ voucher_did: str = Field(..., description="DID of the sponsorship agent")
187
+ vouchee_did: str = Field(..., description="DID of the agent being vouched for")
188
+ voucher_sigma: float = Field(..., description="Sponsor's raw reputation score")
189
+ bond_pct: float | None = None
190
+ expiry: str | None = None
191
+
192
+
193
+ class VouchResponse(BaseModel):
194
+ """Response after creating a sponsor."""
195
+
196
+ vouch_id: str
197
+ voucher_did: str
198
+ vouchee_did: str
199
+ session_id: str
200
+ bonded_amount: float
201
+ bonded_sigma_pct: float
202
+ is_active: bool
203
+
204
+
205
+ class LiabilityExposureResponse(BaseModel):
206
+ """Agent's liability exposure across sessions."""
207
+
208
+ agent_did: str
209
+ vouches_given: list[VouchResponse]
210
+ vouches_received: list[VouchResponse]
211
+ total_exposure: float
212
+
213
+
214
+ # ── Event models ────────────────────────────────────────────────────────────
215
+
216
+ class EventResponse(BaseModel):
217
+ """Serialized hypervisor event."""
218
+
219
+ event_id: str
220
+ event_type: str
221
+ timestamp: str
222
+ session_id: str | None = None
223
+ agent_did: str | None = None
224
+ causal_trace_id: str | None = None
225
+ payload: dict[str, Any] = {}
226
+
227
+
228
+ class EventStatsResponse(BaseModel):
229
+ """Event type counts."""
230
+
231
+ total_events: int
232
+ by_type: dict[str, int]
233
+
234
+
235
+ # ── Stats models ────────────────────────────────────────────────────────────
236
+
237
+ class StatsResponse(BaseModel):
238
+ """Overall hypervisor statistics."""
239
+
240
+ version: str
241
+ total_sessions: int
242
+ active_sessions: int
243
+ total_participants: int
244
+ active_sagas: int
245
+ total_vouches: int
246
+ event_count: int
247
+
248
+
249
+ # ── Audit models ────────────────────────────────────────────────────────────
250
+
251
+ class CommitmentResponse(BaseModel):
252
+ session_id: str
253
+ hash_chain_root: str
254
+ participant_dids: list[str]
255
+ delta_count: int
256
+ committed_at: str
257
+ committed_to: str = "local"
258
+ blockchain_tx_id: str | None = None
259
+
260
+ class VerifyCommitmentResponse(BaseModel):
261
+ session_id: str
262
+ valid: bool
263
+ committed_root: str
264
+ expected_root: str
265
+
266
+ # ── Verification models ─────────────────────────────────────────────────────
267
+
268
+ class TransactionInput(BaseModel):
269
+ session_id: str
270
+ summary_hash: str
271
+ timestamp: datetime
272
+ participant_count: int = 0
273
+
274
+ class VerifyHistoryRequest(BaseModel):
275
+ agent_did: str
276
+ transactions: list[TransactionInput]
277
+
278
+ class VerifyHistoryResponse(BaseModel):
279
+ agent_did: str
280
+ status: str
281
+ transactions_checked: int
282
+ transactions_found: int
283
+ inconsistencies: list[str]
284
+ is_trustworthy: bool
285
+ cached: bool = False