This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
BitBuilder Hypervisor is a revolutionary git-ops-native, multi-tenant hypervisor platform built on systemd's advanced virtualization capabilities. This is primarily an architecture specification project with extensive documentation, template definitions, and reference implementations rather than traditional source code.
The entire system leverages systemd ecosystem components:
systemd-vmspawnandsystemd-nspawnfor virtualizationsystemd-networkdfor network managementsystemd-bootwith UKI (Unified Kernel Images)systemd-import-generatorfor DDI (Discoverable Disk Images)- Custom systemd generators for tenant discovery and unit creation
- Git repositories serve as single source of truth for all configuration
- Each tenant has its own dedicated Git repository
- All infrastructure changes must go through Git commits
- Automatic rollback capability through Git history
- Host OS completely immutable after boot
- All changes applied through layered overlays (sysext/confext)
- Configuration drift eliminated by design
Templates follow strict filesystem hierarchy patterns:
tenant-<name>/
├── metadata.json # Required tenant metadata with JSON schema
├── infrastructure/ # Infrastructure manager config
├── network/ # systemd-networkd configurations
├── machines/ # VM definitions (systemd-vmspawn)
├── containers/ # Container definitions (systemd-nspawn)
├── extensions/ # Extension images
│ ├── sysext/ # System extensions (/usr, /opt only)
│ └── confext/ # Config extensions (/etc only)
├── services/ # Portable service definitions
└── scripts/ # Lifecycle hooks
Strict adherence to UAPI specifications:
- Discoverable Partitions Specification (DPS) for partition layout
- Discoverable Disk Image (DDI) for system images
- Unified Kernel Image (UKI) for secure boot
- Boot Loader Specification (BLS) for boot configuration
- Configuration Files Specification for directory hierarchy
README.md- Main project overview and feature descriptions.github/copilot-instructions.md- Comprehensive AI agent instructionsSTACK.md- Template system and implementation detailsspecs/ARCHITECTURE.md- System architecture and design patternsspecs/DESIGN.md- Technical implementation details
- Templates are defined in documentation but runtime locations are:
/usr/lib/bitbuilder/templates/- System-wide templates/var/lib/tenants/<id>/- Per-tenant runtime data/etc/systemd/system/- systemd unit templates/usr/lib/systemd/system-generators/- Custom generators
This is primarily a specification project without traditional build processes, but key operations include:
# Validate filesystem hierarchy compliance
./scripts/validate-template.sh <template-directory>
# Validate tenant metadata schema
./scripts/validate-metadata.sh metadata.json# Generate systemd units for tenant
systemctl enable --now tenant@<tenant-id>.service
# Reload systemd after generator changes
systemctl daemon-reload
# Check tenant status
systemctl status tenant@<tenant-id>
systemctl status tenant-infra@<tenant-id>
systemctl status tenant-network@<tenant-id># Create sysext extension image
mksquashfs extension-root extension-name.raw
# Mount extension for testing
systemd-sysext refresh
# List active extensions
systemd-sysext status# System repository operations
git -C /var/lib/bitbuilder/system pull
systemctl reload tenant-manager
# Tenant repository sync
git -C /var/lib/tenants/<tenant>/config.git pull
systemctl restart tenant@<tenant>Each tenant operates with multiple security boundaries:
- Hardware: VT-x/AMD-V virtualization, UEFI Secure Boot
- Kernel: Complete namespace isolation (PID, NET, MNT, UTS, IPC, USER)
- SystemD: Capability dropping, seccomp filters, resource limits
- Network: Dedicated bridges, VLANs, network namespaces
- Varlink: Primary IPC protocol for service communication
- SO_PEERCRED: Unix socket authentication
- systemd-creds: Secure credential management
When creating or modifying templates:
- Always include proper
metadata.jsonwith schema validation - Ensure filesystem hierarchy compliance (see validation scripts)
- Extension images must include proper
extension-releasefiles - Test systemd unit generation and dependency resolution
- Verify mount overlay functionality works correctly
- Create tenant Git repository with
metadata.json - systemd generators discover new tenant at boot
- Clone tenant repository to
/var/lib/tenants/<id>/config.git/ - Generate systemd units dynamically
- Apply sysext/confext overlays
- Launch systemd-vmspawn or systemd-nspawn instance
- Execute provisioning scripts
- All changes through Git commits
- Automatic validation and schema checking
- Hot-reload for config changes, restart for structural changes
- Rollback through Git revert
/var/lib/tenants/<id>/- Per-tenant data/var/lib/bitbuilder/- System configuration cache/usr/lib/extensions/- System-wide extension images/etc/voa/and/usr/share/voa/- Verification of OS Artifacts
/etc/systemd/network/- Network configuration templates/usr/lib/systemd/system/- SystemD unit templates/usr/lib/systemd/system-generators/- Custom generators
This project represents a paradigm shift toward declarative, immutable infrastructure management through Git-Ops and systemd's advanced virtualization capabilities.