# Karapace Hash Contract ## Overview The environment identity (`env_id`) is a deterministic blake3 hash that uniquely identifies an environment's fully resolved state. Two identical lock files on any machine must produce the same `env_id`. ## Algorithm Blake3 (256-bit output, hex-encoded, 64 characters). ## Two-Phase Identity Karapace computes identity in two phases: ### Preliminary Identity (`compute_env_id`) Used only during `init` (before resolution) and for internal lookup. Computed from unresolved manifest data. **Not the canonical identity.** ### Canonical Identity (`LockFile::compute_identity`) The authoritative identity used after `build`. Computed from the fully resolved lock file state. This is what gets stored in metadata and the lock file. ## Canonical Hash Input The canonical hash includes the following inputs, fed in order: 1. **Base image content digest**: `base_digest:` — real content hash, not a tag name hash. 2. **Resolved packages**: each as `pkg:@` (sorted by name). 3. **Resolved apps**: each as `app:` (sorted). 4. **Hardware policy**: `hw:gpu` if GPU enabled, `hw:audio` if audio enabled. 5. **Mount policy**: each as `mount: