---
phase: 2
slug: core-vm-lifecycle
status: complete
nyquist_compliant: true
wave_0_complete: true
created: 2026-03-24
---

# Phase 2 — Validation Strategy

> Per-phase validation contract for feedback sampling during execution.

---

## Test Infrastructure

| Property | Value |
|----------|-------|
| **Framework** | pytest 8.x |
| **Config file** | pyproject.toml |
| **Quick run command** | `.venv/bin/pytest tests/test_cluster_define.py tests/test_cluster_lifecycle.py tests/test_cluster_status.py -x -q` |
| **Full suite command** | `.venv/bin/pytest tests/ -q` |
| **Estimated runtime** | ~8 seconds |

---

## Sampling Rate

- **After every task commit:** Run `.venv/bin/pytest tests/test_cluster_define.py tests/test_cluster_lifecycle.py tests/test_cluster_status.py -x -q`
- **After every plan wave:** Run `.venv/bin/pytest tests/ -q`
- **Before `/gsd:verify-work`:** Full suite must be green
- **Max feedback latency:** 15 seconds

---

## Per-Task Verification Map

| Task ID | Plan | Wave | Requirement | Test Type | Automated Command | File Exists | Status |
|---------|------|------|-------------|-----------|-------------------|-------------|--------|
| 02-01-01 | 01 | 1 | CLUS-01 | unit | `.venv/bin/pytest tests/test_libvirt_client.py tests/test_builders.py -x -q` | ✅ | ✅ green |
| 02-02-01 | 02 | 1 | CLUS-01 | unit | `.venv/bin/pytest tests/test_cluster_define.py tests/test_cloud_init.py -x -q` | ✅ | ✅ green |
| 02-02-02 | 02 | 1 | CLUS-07 | unit | `.venv/bin/pytest tests/test_cluster_define.py::test_cluster_define_idempotent -x -q` | ✅ | ✅ green |
| 02-03-01 | 03 | 1 | CLUS-02 | unit | `.venv/bin/pytest tests/test_cluster_lifecycle.py -k "start" -x -q` | ✅ | ✅ green |
| 02-03-02 | 03 | 1 | CLUS-03 | unit | `.venv/bin/pytest tests/test_cluster_lifecycle.py -k "stop" -x -q` | ✅ | ✅ green |
| 02-03-03 | 03 | 1 | CLUS-04 | unit | `.venv/bin/pytest tests/test_cluster_lifecycle.py -k "destroy" -x -q` | ✅ | ✅ green |
| 02-04-01 | 04 | 1 | CLUS-05 | unit | `.venv/bin/pytest tests/test_cluster_status.py -k "status" -x -q` | ✅ | ✅ green |
| 02-04-02 | 04 | 1 | CLUS-06 | unit | `.venv/bin/pytest tests/test_cluster_status.py -k "handle" -x -q` | ✅ | ✅ green |

*Status: ⬜ pending · ✅ green · ❌ red · ⚠️ flaky*

---

## Wave 0 Requirements

Existing infrastructure covers all phase requirements.

---

## Manual-Only Verifications

All phase behaviors have automated verification.

---

## Requirement Coverage

| Requirement | Description | Covered By | Test Names |
|-------------|-------------|------------|------------|
| CLUS-01 | Define cluster from topology — creates libvirt domain definitions and overlay disks | tests/test_cluster_define.py, tests/test_builders.py, tests/test_cloud_init.py | `test_cluster_define_creates_network_and_domains`, `test_cluster_define_creates_overlay_dir`, `test_cluster_define_calls_qemu_img`, `test_build_domain_xml_overlay_disk`, `test_build_network_xml_name`, `test_generate_cloud_init_iso_creates_iso` |
| CLUS-02 | Start all nodes and optionally wait for SSH reachability | tests/test_cluster_lifecycle.py | `test_cluster_start_boots_all_domains`, `test_cluster_start_skips_already_active_domain`, `test_cluster_start_no_wait_returns_immediately`, `test_cluster_start_ssh_success_sets_reachable`, `test_cluster_start_ssh_timeout_returns_failure` |
| CLUS-03 | Stop all nodes gracefully (shutdown) or forcibly (destroy) | tests/test_cluster_lifecycle.py | `test_cluster_stop_shutdown_mode`, `test_cluster_stop_destroy_mode`, `test_cluster_stop_skips_inactive_domains` |
| CLUS-04 | Destroy cluster and optionally remove overlay disk images | tests/test_cluster_lifecycle.py | `test_cluster_destroy_undefines_domains`, `test_cluster_destroy_force_stops_active_domains`, `test_cluster_destroy_always_removes_network`, `test_cluster_destroy_remove_overlays_true`, `test_cluster_destroy_remove_overlays_false` |
| CLUS-05 | Query current status of all nodes (domain state, SSH reachability) | tests/test_cluster_status.py | `test_cluster_status_returns_cluster_name`, `test_cluster_status_network_active_true`, `test_cluster_status_per_node_domain_state`, `test_cluster_status_ssh_checked_only_for_running_nodes`, `test_cluster_status_mixed_states` |
| CLUS-06 | Obtain ClusterHandle descriptor for downstream direct-SSH consumers | tests/test_cluster_status.py | `test_cluster_handle_returns_cluster_name`, `test_cluster_handle_node_descriptors`, `test_cluster_handle_artifact_path`, `test_cluster_handle_kernel_version_from_ssh`, `test_cluster_handle_ssh_key_path_from_topology` |
| CLUS-07 | `cluster_define` is idempotent — safe to call on already-defined cluster | tests/test_cluster_define.py | `test_cluster_define_idempotent` |

---

## Validation Sign-Off

- [x] All tasks have `<automated>` verify or Wave 0 dependencies
- [x] Sampling continuity: no 3 consecutive tasks without automated verify
- [x] Wave 0 covers all MISSING references
- [x] No watch-mode flags
- [x] Feedback latency < 15s
- [x] `nyquist_compliant: true` set in frontmatter

**Approval:** approved 2026-03-24
