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,824 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent_hypervisor
3
+ Version: 3.1.0
4
+ Summary: Public Preview — Agent Hypervisor: Runtime supervisor for multi-agent Shared Sessions with Execution Rings, Joint Liability, Saga Orchestration, and hash-chained audit trails
5
+ Project-URL: Homepage, https://github.com/microsoft/agent-governance-toolkit
6
+ Project-URL: Repository, https://github.com/microsoft/agent-governance-toolkit
7
+ Project-URL: Documentation, https://github.com/microsoft/agent-governance-toolkit#readme
8
+ Project-URL: Bug Tracker, https://github.com/microsoft/agent-governance-toolkit/issues
9
+ Project-URL: Agent OS, https://github.com/microsoft/agent-governance-toolkit
10
+ Project-URL: Agent Mesh, https://github.com/microsoft/agent-governance-toolkit
11
+ Project-URL: Agent SRE, https://github.com/microsoft/agent-governance-toolkit
12
+ Author-email: Microsoft Corporation <agentgovtoolkit@microsoft.com>
13
+ Maintainer-email: Agent Governance Toolkit Team <agentgovtoolkit@microsoft.com>
14
+ License: MIT
15
+ License-File: LICENSE
16
+ Keywords: agents,ai,audit,execution-rings,governance,hash-chain,hypervisor,liability,multi-agent,safety,saga,shared-sessions,trust
17
+ Classifier: Development Status :: 4 - Beta
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Intended Audience :: Science/Research
20
+ Classifier: License :: OSI Approved :: MIT License
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
26
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
+ Classifier: Typing :: Typed
28
+ Requires-Python: >=3.11
29
+ Requires-Dist: pydantic<3.0,>=2.4.0
30
+ Provides-Extra: api
31
+ Requires-Dist: fastapi<1.0,>=0.115.0; extra == 'api'
32
+ Requires-Dist: uvicorn<1.0,>=0.27.0; extra == 'api'
33
+ Provides-Extra: blockchain
34
+ Requires-Dist: web3<8.0,>=6.0.0; extra == 'blockchain'
35
+ Provides-Extra: dev
36
+ Requires-Dist: hypothesis<7.0,>=6.0.0; extra == 'dev'
37
+ Requires-Dist: jsonschema<5.0,>=4.0.0; extra == 'dev'
38
+ Requires-Dist: mypy<2.0,>=1.8.0; extra == 'dev'
39
+ Requires-Dist: pytest-asyncio<2.0,>=0.23.0; extra == 'dev'
40
+ Requires-Dist: pytest-cov<8.0,>=4.0.0; extra == 'dev'
41
+ Requires-Dist: pytest<9.0,>=8.0.0; extra == 'dev'
42
+ Requires-Dist: ruff<1.0,>=0.4.0; extra == 'dev'
43
+ Provides-Extra: full
44
+ Requires-Dist: structlog<26.0,>=24.1.0; extra == 'full'
45
+ Provides-Extra: nexus
46
+ Requires-Dist: structlog<26.0,>=24.1.0; extra == 'nexus'
47
+ Provides-Extra: observability
48
+ Requires-Dist: agent-sre<4.0,>=1.1.0; extra == 'observability'
49
+ Provides-Extra: otel
50
+ Requires-Dist: opentelemetry-api<2.0,>=1.20; extra == 'otel'
51
+ Description-Content-Type: text/markdown
52
+
53
+ <div align="center">
54
+
55
+ # Agent Hypervisor — Public Preview
56
+
57
+ **Execution supervisor for AI agents — runtime isolation, execution rings, and governance for autonomous agents**
58
+
59
+ *Just as a supervisor isolates processes, Agent Hypervisor isolates AI agent sessions<br/>and enforces governance boundaries with a kill switch, blast radius containment, and accountability.*
60
+
61
+ [![CI](https://github.com/microsoft/agent-governance-toolkit/actions/workflows/ci.yml/badge.svg)](https://github.com/microsoft/agent-governance-toolkit/actions/workflows/ci.yml)
62
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](../../LICENSE)
63
+ [![Python](https://img.shields.io/badge/python-3.11+-blue.svg)](https://python.org)
64
+ [![PyPI](https://img.shields.io/pypi/v/agent-hypervisor)](https://pypi.org/project/agent-hypervisor/)
65
+ [![Benchmark](https://img.shields.io/badge/latency-268%CE%BCs%20pipeline-orange)](benchmarks/)
66
+ [![Discussions](https://img.shields.io/github/discussions/microsoft/agent-governance-toolkit)](https://github.com/microsoft/agent-governance-toolkit/discussions)
67
+
68
+ > [!IMPORTANT]
69
+ > **Public Preview** — The `agent-hypervisor` package on PyPI is a Microsoft-signed
70
+ > public preview release. APIs may change before GA.
71
+
72
+ > ⭐ **If this project helps you, please star it!** It helps others discover Agent Hypervisor.
73
+
74
+ > 📦 **Install the full stack:** `pip install agent-governance-toolkit[full]` — [PyPI](https://pypi.org/project/ai-agent-governance/) | [GitHub](https://github.com/microsoft/agent-governance-toolkit)
75
+
76
+ [Quick Start](#quick-start) • [Configuration](#configuration) • [Why a Hypervisor?](#-why-agent-hypervisor) • [Features](#key-features) • [Architecture](#architecture-diagrams) • [Performance](#performance) • [Ecosystem](#ecosystem)
77
+
78
+ </div>
79
+
80
+ ---
81
+
82
+ ### Integrated Into Major AI Frameworks
83
+
84
+ <p align="center">
85
+ <a href="https://github.com/langgenius/dify-plugins/pull/2060"><img src="https://img.shields.io/badge/Dify-65K_%E2%AD%90_Merged-success?style=flat-square" alt="Dify"></a>
86
+ <a href="https://github.com/run-llama/llama_index/pull/20644"><img src="https://img.shields.io/badge/LlamaIndex-47K_%E2%AD%90_Merged-success?style=flat-square" alt="LlamaIndex"></a>
87
+ <a href="https://github.com/github/awesome-copilot/pull/755"><img src="https://img.shields.io/badge/Awesome_Copilot-Merged-success?style=flat-square" alt="Awesome Copilot"></a>
88
+ <a href="https://github.com/microsoft/agent-lightning/pull/478"><img src="https://img.shields.io/badge/Agent--Lightning-15K_%E2%AD%90_Merged-success?style=flat-square" alt="Agent-Lightning"></a>
89
+ <a href="https://github.com/magsther/awesome-opentelemetry/pull/24"><img src="https://img.shields.io/badge/awesome--opentelemetry-listed-orange?style=flat-square" alt="awesome-opentelemetry"></a>
90
+ </p>
91
+
92
+ ## 📊 By The Numbers
93
+
94
+ <table>
95
+ <tr>
96
+ <td align="center"><h3>644+</h3><sub>Tests Passing</sub></td>
97
+ <td align="center"><h3>4</h3><sub>Execution Rings<br/>(Ring 0–3)</sub></td>
98
+ <td align="center"><h3>268μs</h3><sub>Full Governance<br/>Pipeline Latency</sub></td>
99
+ <td align="center"><h3>v2.0</h3><sub>Saga Compensation<br/>Kill Switch · Rate Limits</sub></td>
100
+ </tr>
101
+ </table>
102
+
103
+ ## 💡 Why Agent Hypervisor?
104
+
105
+ > **The problem:** AI agents run with unlimited resources, no isolation, and no kill switch. A single rogue agent in a shared session can escalate privileges, corrupt state, or cascade failures across your entire system.
106
+
107
+ > **Our solution:** A hypervisor that enforces execution rings, resource limits, saga compensation, and runtime governance — giving you a kill switch, blast radius containment, and joint liability for agent accountability.
108
+
109
+ ### How It Maps to What You Already Know
110
+
111
+ | OS / VM Hypervisor | Agent Hypervisor | Why It Matters |
112
+ |-------------------|-----------------|----------------|
113
+ | CPU rings (Ring 0–3) | **Execution Rings** — privilege levels based on trust score | Graduated access, not binary allow/deny |
114
+ | Process isolation | **Session isolation** — VFS namespacing, DID-bound identity | Rogue agents can't corrupt other sessions |
115
+ | Memory protection | **Liability protection** — bonded reputation, collateral slash | Sponsors have skin in the game |
116
+ | System calls | **Saga transactions** — multi-step ops with automatic rollback | Failed workflows undo themselves |
117
+ | Watchdog timer | **Kill switch** — graceful termination with step handoff | Stop runaway agents without data loss |
118
+ | Audit logs | **Hash-chained delta trail** — tamper-evident forensic trail | Prove exactly what happened |
119
+
120
+ ## Quick Start
121
+
122
+ ```bash
123
+ pip install agent-hypervisor
124
+ ```
125
+
126
+ ```python
127
+ from hypervisor import Hypervisor, SessionConfig, ConsistencyMode
128
+
129
+ hv = Hypervisor()
130
+
131
+ # Create an isolated session with governance
132
+ session = await hv.create_session(
133
+ config=SessionConfig(enable_audit=True),
134
+ creator_did="did:mesh:admin",
135
+ )
136
+
137
+ # Agent joins — ring assigned automatically by trust score
138
+ ring = await hv.join_session(
139
+ session.sso.session_id,
140
+ "did:mesh:agent-1",
141
+ sigma_raw=0.85,
142
+ )
143
+ # → RING_2_STANDARD (trusted agent)
144
+
145
+ # Activate and run a governed saga
146
+ await hv.activate_session(session.sso.session_id)
147
+ saga = session.saga.create_saga(session.sso.session_id)
148
+ step = session.saga.add_step(
149
+ saga.saga_id, "draft_email", "did:mesh:agent-1",
150
+ execute_api="/api/draft", undo_api="/api/undo-draft",
151
+ timeout_seconds=30, max_retries=2,
152
+ )
153
+ result = await session.saga.execute_step(
154
+ saga.saga_id, step.step_id, executor=draft_email,
155
+ )
156
+
157
+ # Terminate — returns tamper-evident audit hash
158
+ hash_root = await hv.terminate_session(session.sso.session_id)
159
+ ```
160
+
161
+ ## Configuration
162
+
163
+ This section covers how to configure agents, sessions, sagas, security, and rate limiting.
164
+
165
+ ### Agent Configuration
166
+
167
+ Agents join sessions and are assigned an **Execution Ring** based on their trust score (`eff_score`). You can control ring assignment, resource limits, and timeouts.
168
+
169
+ ```python
170
+ from hypervisor import Hypervisor, SessionConfig, ConsistencyMode, ExecutionRing
171
+
172
+ # Initialize with optional liability cap and retention policy
173
+ hv = Hypervisor(
174
+ max_exposure=1000.0, # Max total liability per voucher
175
+ retention_policy=None, # Ephemeral GC rules (default: keep all)
176
+ )
177
+
178
+ # Create a session with resource limits
179
+ session = await hv.create_session(
180
+ config=SessionConfig(
181
+ consistency_mode=ConsistencyMode.EVENTUAL, # or STRONG
182
+ max_participants=10, # 1–1000
183
+ max_duration_seconds=3600, # 1–604,800 (7 days max)
184
+ min_eff_score=0.60, # Minimum trust score to join
185
+ enable_audit=True, # Hash-chained audit trail
186
+ enable_blockchain_commitment=False,
187
+ ),
188
+ creator_did="did:mesh:admin",
189
+ )
190
+
191
+ # Agent joins — ring assigned by trust score
192
+ ring = await hv.join_session(
193
+ session.sso.session_id,
194
+ "did:mesh:agent-1",
195
+ sigma_raw=0.85, # Raw trust score [0.0–1.0]
196
+ )
197
+ # Ring assignment thresholds:
198
+ # eff_score > 0.95 + consensus → RING_1_PRIVILEGED
199
+ # eff_score > 0.60 → RING_2_STANDARD
200
+ # otherwise → RING_3_SANDBOX (default)
201
+ ```
202
+
203
+ ### Temporary Ring Elevation (Sudo)
204
+
205
+ Agents can request temporary privilege escalation with a TTL:
206
+
207
+ > **Note:** Ring elevation is available in the Enterprise Edition. Public Preview includes the API surface but returns a denial response. See the architecture for how it works.
208
+
209
+ ```python
210
+ from hypervisor import RingElevationManager
211
+
212
+ elevation_mgr = RingElevationManager()
213
+
214
+ # Grant temporary Ring 1 access (max 3600s, default 300s)
215
+ elevation = elevation_mgr.elevate(
216
+ agent_did="did:mesh:agent-1",
217
+ session_id=session.sso.session_id,
218
+ target_ring=ExecutionRing.RING_1_PRIVILEGED,
219
+ ttl_seconds=300, # Auto-expires after 5 minutes
220
+ reason="deploy-approval",
221
+ attestation="signed-by-sre", # Optional proof
222
+ )
223
+
224
+ # Revoke early if needed
225
+ elevation_mgr.revoke(elevation.elevation_id)
226
+ ```
227
+
228
+ ### Session Configuration
229
+
230
+ `SessionConfig` controls isolation, participant limits, and consistency:
231
+
232
+ ```python
233
+ from hypervisor import SessionConfig, ConsistencyMode
234
+
235
+ config = SessionConfig(
236
+ consistency_mode=ConsistencyMode.STRONG, # Requires consensus
237
+ max_participants=5,
238
+ max_duration_seconds=7200, # 2-hour session
239
+ min_eff_score=0.70, # Higher trust threshold
240
+ enable_audit=True,
241
+ enable_blockchain_commitment=True,
242
+ )
243
+
244
+ session = await hv.create_session(config=config, creator_did="did:mesh:admin")
245
+ await hv.activate_session(session.sso.session_id)
246
+
247
+ # Session lifecycle: CREATED → HANDSHAKING → ACTIVE → TERMINATING → ARCHIVED
248
+ ```
249
+
250
+ ### Saga Configuration
251
+
252
+ Define multi-step transactions with compensation using the DSL parser or programmatically:
253
+
254
+ ```python
255
+ from hypervisor import SagaDSLParser, SagaOrchestrator, FanOutPolicy
256
+
257
+ # Option 1: Define saga as a dict (or load from YAML)
258
+ definition = {
259
+ "name": "deploy-pipeline",
260
+ "session_id": "ss-a1b2c3d4",
261
+ "steps": [
262
+ {
263
+ "id": "provision",
264
+ "action_id": "provision-vm",
265
+ "agent": "did:mesh:agent-1",
266
+ "execute_api": "/infra/provision",
267
+ "undo_api": "/infra/deprovision", # Compensation endpoint
268
+ "timeout": 120, # Seconds (default: 300)
269
+ "retries": 2, # Retry count (default: 0)
270
+ },
271
+ {
272
+ "id": "deploy",
273
+ "action_id": "deploy-app",
274
+ "agent": "did:mesh:agent-2",
275
+ "execute_api": "/app/deploy",
276
+ "undo_api": "/app/undeploy",
277
+ "timeout": 60,
278
+ },
279
+ ],
280
+ "fan_outs": [
281
+ {
282
+ "policy": "all_must_succeed", # or majority_must_succeed, any_must_succeed
283
+ "branch_step_ids": ["provision", "deploy"],
284
+ },
285
+ ],
286
+ }
287
+
288
+ parser = SagaDSLParser()
289
+ errors = parser.validate(definition) # Returns [] if valid
290
+ saga_def = parser.parse(definition)
291
+ steps = parser.to_saga_steps(saga_def)
292
+
293
+ # Option 2: Build programmatically
294
+ saga = session.saga.create_saga(session.sso.session_id)
295
+ step = session.saga.add_step(
296
+ saga.saga_id, "draft_email", "did:mesh:agent-1",
297
+ execute_api="/api/draft",
298
+ undo_api="/api/undo-draft",
299
+ timeout_seconds=30,
300
+ max_retries=2,
301
+ )
302
+ result = await session.saga.execute_step(
303
+ saga.saga_id, step.step_id, executor=draft_email,
304
+ )
305
+ # On failure: automatic reverse-order compensation of committed steps
306
+ ```
307
+
308
+ ### Kill Switch
309
+
310
+ The kill switch provides graceful agent termination with saga step handoff:
311
+
312
+ ```python
313
+ from hypervisor import KillSwitch
314
+
315
+ kill_switch = KillSwitch()
316
+
317
+ # Terminate a misbehaving agent
318
+ result = kill_switch.kill(
319
+ agent_did="did:mesh:rogue-agent",
320
+ session_id=session.sso.session_id,
321
+ reason="ring_breach", # behavioral_drift | rate_limit | ring_breach | manual
322
+ )
323
+ # result.handoffs — list of in-flight saga steps handed to substitute agents
324
+ # result.compensation_triggered — True if active sagas were compensated
325
+ ```
326
+
327
+ Kill reasons:
328
+ - `behavioral_drift` — Agent behavior diverges from expected patterns
329
+ - `rate_limit` — Agent exceeded rate limit thresholds
330
+ - `ring_breach` — Agent attempted unauthorized ring access
331
+ - `manual` — Operator-initiated termination
332
+ - `quarantine_timeout` — Quarantine period expired without resolution
333
+ - `session_timeout` — Session max duration exceeded
334
+
335
+ ### Rate Limiting
336
+
337
+ Per-ring token bucket rate limiting is applied automatically:
338
+
339
+ ```python
340
+ from hypervisor import AgentRateLimiter
341
+ from hypervisor.rings import ExecutionRing
342
+
343
+ limiter = AgentRateLimiter()
344
+
345
+ # Default per-ring limits (rate tokens/sec, burst capacity):
346
+ # Ring 0 (Root): 100.0 rate, 200.0 capacity
347
+ # Ring 1 (Privileged): 50.0 rate, 100.0 capacity
348
+ # Ring 2 (Standard): 20.0 rate, 40.0 capacity
349
+ # Ring 3 (Sandbox): 5.0 rate, 10.0 capacity
350
+
351
+ # Custom rate limits per ring
352
+ from hypervisor.security.rate_limiter import DEFAULT_RING_LIMITS
353
+ custom_limits = {
354
+ ExecutionRing.RING_0_ROOT: (200.0, 400.0),
355
+ ExecutionRing.RING_1_PRIVILEGED: (100.0, 200.0),
356
+ ExecutionRing.RING_2_STANDARD: (30.0, 60.0),
357
+ ExecutionRing.RING_3_SANDBOX: (2.0, 5.0),
358
+ }
359
+ limiter = AgentRateLimiter(ring_limits=custom_limits)
360
+ ```
361
+
362
+ ### Ring Breach Detection
363
+
364
+ The breach detector monitors agents for anomalous access patterns:
365
+
366
+ ```python
367
+ from hypervisor import RingBreachDetector, BreachSeverity
368
+
369
+ detector = RingBreachDetector()
370
+
371
+ # Breach events include:
372
+ # severity: NONE | LOW | MEDIUM | HIGH | CRITICAL
373
+ # anomaly_score: float — how far the behavior deviates
374
+ # actual_rate vs expected_rate — call frequency anomaly
375
+ # call_count_window — calls in the detection window
376
+
377
+ # Breach detection triggers automatic demotion or kill switch
378
+ ```
379
+
380
+ ### YAML Configuration
381
+
382
+ You can define sagas and load them from YAML files:
383
+
384
+ ```yaml
385
+ # saga-deploy.yaml
386
+ name: deploy-pipeline
387
+ session_id: ss-a1b2c3d4
388
+ steps:
389
+ - id: provision
390
+ action_id: provision-vm
391
+ agent: "did:mesh:agent-1"
392
+ execute_api: /infra/provision
393
+ undo_api: /infra/deprovision
394
+ timeout: 120
395
+ retries: 2
396
+
397
+ - id: deploy
398
+ action_id: deploy-app
399
+ agent: "did:mesh:agent-2"
400
+ execute_api: /app/deploy
401
+ undo_api: /app/undeploy
402
+ timeout: 60
403
+ retries: 1
404
+
405
+ fan_outs:
406
+ - policy: all_must_succeed
407
+ branch_step_ids:
408
+ - provision
409
+ - deploy
410
+
411
+ metadata:
412
+ environment: production
413
+ owner: platform-team
414
+ ```
415
+
416
+ ```python
417
+ import yaml
418
+ from hypervisor import SagaDSLParser
419
+
420
+ with open("saga-deploy.yaml") as f:
421
+ definition = yaml.safe_load(f)
422
+
423
+ parser = SagaDSLParser()
424
+ errors = parser.validate(definition)
425
+ if not errors:
426
+ saga_def = parser.parse(definition)
427
+ ```
428
+
429
+ ### Docker Compose
430
+
431
+ For production deployments with Redis-backed state:
432
+
433
+ ```yaml
434
+ # docker-compose.yml
435
+ services:
436
+ redis:
437
+ image: redis:7-alpine
438
+ ports:
439
+ - "6379:6379"
440
+
441
+ hypervisor-api:
442
+ build: .
443
+ environment:
444
+ - REDIS_URL=redis://redis:6379/0
445
+ - HYPERVISOR_CONFIG=/app/config/hypervisor.yaml
446
+ ports:
447
+ - "8000:8000"
448
+ volumes:
449
+ - ./config:/app/config
450
+ ```
451
+
452
+ ## Configuration Reference
453
+
454
+ | Parameter | Type | Default | Description |
455
+ |-----------|------|---------|-------------|
456
+ | **Hypervisor** | | | |
457
+ | `max_exposure` | `float` | `None` | Maximum total liability per voucher |
458
+ | `retention_policy` | `RetentionPolicy` | `None` | Ephemeral GC rules for audit data |
459
+ | `nexus` | adapter | `None` | External trust scoring backend |
460
+ | `policy_check` | adapter | `None` | Behavioral verification adapter |
461
+ | `iatp` | adapter | `None` | Capability manifest parser |
462
+ | **SessionConfig** | | | |
463
+ | `consistency_mode` | `ConsistencyMode` | `EVENTUAL` | `STRONG` (consensus) or `EVENTUAL` (gossip) |
464
+ | `max_participants` | `int` | `10` | Max agents per session (1–1,000) |
465
+ | `max_duration_seconds` | `int` | `3600` | Session timeout (1–604,800) |
466
+ | `min_eff_score` | `float` | `0.60` | Minimum trust score to join (0.0–1.0) |
467
+ | `enable_audit` | `bool` | `True` | Enable hash-chained audit trail |
468
+ | `enable_blockchain_commitment` | `bool` | `False` | Commit audit hashes to blockchain |
469
+ | **Execution Rings** | | | |
470
+ | `RING_0_ROOT` | `int` | `0` | Hypervisor config & penalty (SRE Witness required) |
471
+ | `RING_1_PRIVILEGED` | `int` | `1` | Non-reversible actions (eff_score > 0.95 + consensus) |
472
+ | `RING_2_STANDARD` | `int` | `2` | Reversible actions (eff_score > 0.60) |
473
+ | `RING_3_SANDBOX` | `int` | `3` | Read-only / research (default) |
474
+ | **Ring Elevation** | | | |
475
+ | `ttl_seconds` | `int` | `300` | Elevation duration (max 3,600s) |
476
+ | `reason` | `str` | `""` | Justification for elevation |
477
+ | `attestation` | `str` | `None` | Signed proof from authorizer |
478
+ | **Saga Steps** | | | |
479
+ | `timeout` | `int` | `300` | Step timeout in seconds |
480
+ | `retries` | `int` | `0` | Max retry attempts |
481
+ | `execute_api` | `str` | — | Endpoint for step execution |
482
+ | `undo_api` | `str` | `None` | Endpoint for compensation |
483
+ | `checkpoint_goal` | `str` | `None` | Checkpoint description for replay |
484
+ | **Fan-Out Policy** | | | |
485
+ | `ALL_MUST_SUCCEED` | — | ✓ | All branches must complete |
486
+ | `MAJORITY_MUST_SUCCEED` | — | — | >50% of branches must complete |
487
+ | `ANY_MUST_SUCCEED` | — | — | At least one branch must complete |
488
+ | **Rate Limits** (tokens/sec, burst) | | | |
489
+ | Ring 0 (Root) | `(float, float)` | `(100.0, 200.0)` | Highest throughput for admin ops |
490
+ | Ring 1 (Privileged) | `(float, float)` | `(50.0, 100.0)` | High throughput for trusted agents |
491
+ | Ring 2 (Standard) | `(float, float)` | `(20.0, 40.0)` | Moderate throughput |
492
+ | Ring 3 (Sandbox) | `(float, float)` | `(5.0, 10.0)` | Restricted throughput |
493
+ | **Kill Switch** | | | |
494
+ | `reason` | `KillReason` | — | `behavioral_drift`, `rate_limit`, `ring_breach`, `manual`, `quarantine_timeout`, `session_timeout` |
495
+ | **Breach Detection** | | | |
496
+ | `severity` | `BreachSeverity` | — | `NONE`, `LOW`, `MEDIUM`, `HIGH`, `CRITICAL` |
497
+
498
+ ## Architecture Diagrams
499
+
500
+ ### Execution Ring Hierarchy
501
+
502
+ ```mermaid
503
+ graph TD
504
+ R0["🔴 Ring 0 — Root<br/>Hypervisor config & penalty<br/>Requires SRE Witness"]
505
+ R1["🟠 Ring 1 — Privileged<br/>Non-reversible actions<br/>eff_score > 0.95 + consensus"]
506
+ R2["🟡 Ring 2 — Standard<br/>Reversible actions<br/>eff_score > 0.60"]
507
+ R3["🟢 Ring 3 — Sandbox<br/>Read-only / research<br/>Default for unknown agents"]
508
+
509
+ R0 -->|"supervises"| R1
510
+ R1 -->|"supervises"| R2
511
+ R2 -->|"supervises"| R3
512
+ ```
513
+
514
+ ### Ring Promotion / Demotion Flow
515
+
516
+ ```mermaid
517
+ stateDiagram-v2
518
+ [*] --> Ring3 : Agent joins session
519
+ Ring3 --> Ring2 : eff_score rises above 0.60
520
+ Ring2 --> Ring1 : eff_score > 0.95 + consensus
521
+ Ring1 --> Ring0 : SRE Witness approval
522
+
523
+ Ring0 --> Ring1 : Trust drops / TTL expires
524
+ Ring1 --> Ring2 : Trust drops below 0.95
525
+ Ring2 --> Ring3 : Trust drops below 0.60
526
+ Ring3 --> [*] : Terminated / expelled
527
+
528
+ Ring2 --> Ring1 : Sudo elevation (TTL)
529
+ Ring1 --> Ring2 : TTL expires
530
+
531
+ note right of Ring3 : Ring breach detection\ntriggers immediate demotion
532
+ ```
533
+
534
+ ### Saga Lifecycle
535
+
536
+ ```mermaid
537
+ flowchart LR
538
+ Create["Create Saga"] --> AddSteps["Add Steps"]
539
+ AddSteps --> Execute["Execute Steps"]
540
+ Execute --> Success{"All steps\nsucceed?"}
541
+ Success -- Yes --> Complete["✅ Saga Complete"]
542
+ Success -- No --> Compensate["Compensate\n(reverse order)"]
543
+ Compensate --> CompOk{"Compensation\nsucceeds?"}
544
+ CompOk -- Yes --> Rolled["↩️ Saga Rolled Back"]
545
+ CompOk -- No --> Escalate["⚠️ Escalate\nLiability Penalty"]
546
+ ```
547
+
548
+ ### Joint Liability Vouch Chain
549
+
550
+ ```mermaid
551
+ flowchart TD
552
+ Sponsor["🛡️ Sponsor Agent<br/>eff_score: 0.92<br/>Bonds reputation"]
553
+ Sponsored["🤖 Sponsored Agent<br/>eff_score: 0.45<br/>Gains Ring 2 access"]
554
+ Action["Agent performs action"]
555
+ Check{"Intent\nviolation?"}
556
+ Safe["✅ No penalty"]
557
+ Penalty["🔻 Both penalized<br/>Sponsor collateral slashed<br/>Sponsored demoted"]
558
+
559
+ Sponsor -->|"vouches for"| Sponsored
560
+ Sponsored --> Action
561
+ Action --> Check
562
+ Check -- No --> Safe
563
+ Check -- Yes --> Penalty
564
+ Penalty -->|"collateral slash"| Sponsor
565
+ Penalty -->|"demotion + quarantine"| Sponsored
566
+ ```
567
+
568
+ ### Slash Cascade Propagation
569
+
570
+ ```mermaid
571
+ flowchart TD
572
+ Violation["🚨 Violation Detected"]
573
+ Attr["Fault Attribution<br/>Identify responsible agent"]
574
+ Primary["Primary Agent<br/>Full penalty applied"]
575
+ Sponsor1["Sponsor A<br/>Collateral slashed"]
576
+ Sponsor2["Sponsor B<br/>Collateral slashed"]
577
+ Quarantine["Quarantine Agent<br/>Before termination"]
578
+ Demote["Demote to Ring 3"]
579
+ Ledger["Record in<br/>Liability Ledger"]
580
+
581
+ Violation --> Attr
582
+ Attr --> Primary
583
+ Primary --> Sponsor1
584
+ Primary --> Sponsor2
585
+ Primary --> Quarantine
586
+ Quarantine --> Demote
587
+ Sponsor1 --> Ledger
588
+ Sponsor2 --> Ledger
589
+ Primary --> Ledger
590
+ ```
591
+
592
+ ## Key Features
593
+
594
+ <table>
595
+ <tr>
596
+ <td width="50%">
597
+
598
+ ### 🔐 Execution Rings
599
+ Hardware-inspired privilege model (Ring 0–3). Agents earn ring access based on trust score. Real-time demotion on trust drops. Sudo elevation with TTL. Breach detection with circuit breakers.
600
+
601
+ </td>
602
+ <td width="50%">
603
+
604
+ ### 🛑 Kill Switch
605
+ Graceful termination with saga step handoff to substitute agents. Rate limiting per agent per ring (sandbox: 5 rps, root: 100 rps). Stop runaway agents without data loss.
606
+
607
+ </td>
608
+ </tr>
609
+ <tr>
610
+ <td width="50%">
611
+
612
+ ### 🔄 Saga Compensation
613
+ Multi-step transactions with timeout enforcement, retry with backoff, reverse-order compensation, and escalation to liability. Parallel execution with ALL/MAJORITY/ANY policies.
614
+
615
+ </td>
616
+ <td width="50%">
617
+
618
+ ### 🤝 Joint Liability
619
+ High-trust agents sponsor low-trust agents by bonding reputation. If the sponsored agent violates intent, **both are penalized**. Fault attribution, quarantine-before-terminate, persistent ledger.
620
+
621
+ </td>
622
+ </tr>
623
+ <tr>
624
+ <td width="50%">
625
+
626
+ ### 📋 Hash-Chained Audit
627
+ Forensic-grade delta trails — semantic diffs, hash-chained entries, summary commitment at session end. Garbage collection preserves forensic artifacts.
628
+
629
+ </td>
630
+ <td width="50%">
631
+
632
+ ### 📡 Observability
633
+ Structured event bus emits typed events for every action. Causal trace IDs with full delegation tree encoding. Version counters for causal consistency. **Prometheus metrics collector** for ring transitions and breaches. **OpenTelemetry span exporter** for saga-to-span mapping with distributed trace context.
634
+
635
+ </td>
636
+ </tr>
637
+ </table>
638
+
639
+ <details>
640
+ <summary><b>📖 Feature details (click to expand)</b></summary>
641
+
642
+ ### 🔐 Execution Rings — Deep Dive
643
+
644
+ ```
645
+ Ring 0 (Root) — Hypervisor config & penalty — requires SRE Witness
646
+ Ring 1 (Privileged) — Non-reversible actions — requires eff_score > 0.95 + consensus
647
+ Ring 2 (Standard) — Reversible actions — requires eff_score > 0.60
648
+ Ring 3 (Sandbox) — Read-only / research — default for unknown agents
649
+ ```
650
+
651
+ **v2.0 additions:** Dynamic ring elevation (sudo with TTL), ring breach detection with circuit breakers, ring inheritance for spawned agents, **behavioral anomaly detection** with sliding-window rate analysis and ring-distance amplification.
652
+
653
+ ### 🔄 Saga Orchestrator — Deep Dive
654
+
655
+ - **Timeout enforcement** — steps that hang are automatically cancelled
656
+ - **Retry with backoff** — transient failures retry with exponential delay
657
+ - **Reverse-order compensation** — on failure, all committed steps are undone
658
+ - **Escalation** — if compensation fails, Joint Liability penalty is triggered
659
+ - **Parallel execution** — ALL_MUST_SUCCEED / MAJORITY / ANY policies
660
+ - **Execution checkpoints** — partial replay without re-running completed effects
661
+ - **Declarative DSL** — define sagas via YAML or dict
662
+
663
+ ### 🔒 Session Consistency
664
+
665
+ - **Version counters** — causal consistency for shared VFS state
666
+ - **Resource locks** — READ/WRITE/EXCLUSIVE with lock timeout
667
+ - **Isolation levels** — SNAPSHOT, READ_COMMITTED, SERIALIZABLE per saga
668
+
669
+ </details>
670
+
671
+ ## Performance
672
+
673
+ | Operation | Mean Latency | Throughput |
674
+ |-----------|-------------|------------|
675
+ | Ring computation | **0.3μs** | 3.75M ops/s |
676
+ | Delta audit capture | **27μs** | 26K ops/s |
677
+ | Session lifecycle | **54μs** | 15.7K ops/s |
678
+ | 3-step saga | **151μs** | 5.3K ops/s |
679
+ | **Full governance pipeline** | **268μs** | **2,983 ops/s** |
680
+
681
+ > Full pipeline = session create + agent join + 3 audit deltas + saga step + terminate with audit log root
682
+
683
+ ## Installation
684
+
685
+ ```bash
686
+ pip install agent-hypervisor
687
+ ```
688
+
689
+ ## Modules
690
+
691
+ | Module | Description | Tests |
692
+ |--------|-------------|-------|
693
+ | `hypervisor.session` | Shared Session Object lifecycle + VFS | 52 |
694
+ | `hypervisor.rings` | 4-ring privilege + elevation + breach detection | 34 |
695
+ | `hypervisor.liability` | Sponsorship, penalty, attribution, quarantine, ledger | 39 |
696
+ | `hypervisor.reversibility` | Execute/Undo API registry | 4 |
697
+ | `hypervisor.saga` | Saga orchestrator + fan-out + checkpoints + DSL | 41 |
698
+ | `hypervisor.audit` | Delta engine, audit log, GC, commitment | 10 |
699
+ | `hypervisor.verification` | DID transaction history verification | 4 |
700
+ | `hypervisor.observability` | Event bus, causal trace IDs | 22 |
701
+ | `hypervisor.security` | Rate limiter, kill switch | 16 |
702
+ | `hypervisor.integrations` | Nexus, Verification, IATP cross-module adapters | -- |
703
+ | **Integration** | End-to-end lifecycle, edge cases, security | **24** |
704
+ | **Scenarios** | Cross-module governance pipelines (7 suites) | **18** |
705
+ | **Total** | | **644** |
706
+
707
+ ## Test Suite
708
+
709
+ ```bash
710
+ # Run all tests
711
+ pytest tests/ -v
712
+
713
+ # Run only integration tests
714
+ pytest tests/integration/ -v
715
+
716
+ # Run benchmarks
717
+ python benchmarks/bench_hypervisor.py
718
+ ```
719
+
720
+ ## Cross-Module Integrations
721
+
722
+ The Hypervisor supports optional integration with external trust scoring, behavioral verification, and capability manifest systems via adapters in `hypervisor.integrations`. See the adapter modules for usage examples.
723
+
724
+ ### REST API
725
+
726
+ Full FastAPI REST API with 22 endpoints and interactive Swagger docs:
727
+
728
+ ```bash
729
+ pip install agent-hypervisor[api]
730
+ uvicorn hypervisor.api.server:app
731
+ # Open http://localhost:8000/docs for Swagger UI
732
+ ```
733
+
734
+ Endpoints: Sessions, Rings, Sagas, Liability, Events, Health.
735
+
736
+ ### Visualization Dashboard
737
+
738
+ Interactive Streamlit dashboard with 5 tabs:
739
+
740
+ ```bash
741
+ cd examples/dashboard
742
+ pip install -r requirements.txt
743
+ streamlit run app.py
744
+ ```
745
+
746
+ Tabs: Session Overview | Execution Rings | Saga Orchestration | Liability & Trust | Event Stream
747
+
748
+ ## Ecosystem
749
+
750
+ Agent Hypervisor is part of the **Agent Governance Ecosystem** — four specialized repos that work together:
751
+
752
+ ```mermaid
753
+ graph TB
754
+ subgraph Ecosystem["Agent Governance Ecosystem"]
755
+ OS["🧠 Agent OS<br/>Policy Enforcement Kernel"]
756
+ Mesh["🔗 Agent Mesh<br/>Cryptographic Trust Network"]
757
+ SRE["📊 Agent SRE<br/>Reliability Platform"]
758
+ HV["⚡ Agent Hypervisor<br/>Runtime Governance"]
759
+
760
+ OS <-->|"policies"| HV
761
+ Mesh <-->|"trust scores"| HV
762
+ SRE <-->|"SLOs + chaos"| HV
763
+ OS <-->|"identity"| Mesh
764
+ end
765
+
766
+ style HV fill:#ff6b6b,stroke:#333,color:#fff
767
+ ```
768
+
769
+ | Repo | Role | Stars |
770
+ |------|------|-------|
771
+ | [Agent OS](https://github.com/microsoft/agent-governance-toolkit) | Policy enforcement kernel | 1,500+ tests |
772
+ | [Agent Mesh](https://github.com/microsoft/agent-governance-toolkit) | Cryptographic trust network | 1,400+ tests |
773
+ | [Agent SRE](https://github.com/microsoft/agent-governance-toolkit) | SLO, chaos, cost guardrails | 1,070+ tests |
774
+ | **Agent Hypervisor** | Session isolation & governance runtime | 644+ tests |
775
+
776
+ ## 🗺️ Roadmap
777
+
778
+ | Quarter | Milestone |
779
+ |---------|-----------|
780
+ | **Q1 2026** | ✅ v2.0 — Execution rings, saga orchestration, joint liability, shared sessions |
781
+ | **Q2 2026** | Distributed hypervisor (multi-node), WebSocket real-time dashboard, Redis-backed sessions |
782
+ | **Q3 2026** | Kubernetes operator for auto-scaling ring policies, CNCF Sandbox application |
783
+ | **Q4 2026** | v3.0 — Federated hypervisor mesh, cross-org agent governance, SOC2 attestation |
784
+
785
+ ---
786
+
787
+ ## Frequently Asked Questions
788
+
789
+ **Why use a hypervisor for AI agents?**
790
+ Just as OS hypervisors isolate virtual machines and enforce resource boundaries, an agent hypervisor isolates AI agent sessions and enforces governance boundaries. Without isolation, a misbehaving agent in a shared session can corrupt state, escalate privileges, or cascade failures across the entire system.
791
+
792
+ **How do Execution Rings differ from traditional access control?**
793
+ Traditional access control is static and binary (allowed/denied). Execution Rings are dynamic and graduated -- agents earn ring privileges based on their trust score, can request temporary elevation with TTL (like `sudo`), and are automatically demoted when trust drops. Ring breach detection catches anomalous behavior before damage occurs.
794
+
795
+ **What happens when a multi-agent saga fails?**
796
+ The Saga Orchestrator triggers reverse-order compensation for all committed steps. For parallel execution sagas, the failure policy determines the response: ALL_MUST_SUCCEED compensates if any branch fails, MAJORITY allows minority failures, and ANY succeeds if at least one branch completes. Execution checkpoints enable partial replay without re-running completed effects.
797
+
798
+ **How does fault attribution work?**
799
+ When a saga fails, the hypervisor identifies the agent responsible for the failure and triggers appropriate liability consequences.
800
+
801
+ ## Contributing
802
+
803
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
804
+
805
+ - :bug: [Report a Bug](https://github.com/microsoft/agent-governance-toolkit/issues/new?labels=bug)
806
+ - :bulb: [Request a Feature](https://github.com/microsoft/agent-governance-toolkit/issues/new?labels=enhancement)
807
+ - :speech_balloon: [Join Discussions](https://github.com/microsoft/agent-governance-toolkit/discussions)
808
+ - Look for issues labeled [`good first issue`](https://github.com/microsoft/agent-governance-toolkit/labels/good%20first%20issue) to get started
809
+
810
+ ## License
811
+
812
+ MIT -- see [LICENSE](LICENSE).
813
+
814
+ ---
815
+
816
+ <div align="center">
817
+
818
+ **[Agent OS](https://github.com/microsoft/agent-governance-toolkit)** | **[AgentMesh](https://github.com/microsoft/agent-governance-toolkit)** | **[Agent SRE](https://github.com/microsoft/agent-governance-toolkit)** | **[Agent Hypervisor](https://github.com/microsoft/agent-governance-toolkit)**
819
+
820
+ *Built with :heart: for the AI agent governance community*
821
+
822
+ If Agent Hypervisor helps your work, please consider giving it a :star:
823
+
824
+ </div>