# `SnakeBridge.Lock`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/lock.ex#L1)

Manages snakebridge.lock with runtime identity, hardware info, and library versions.

The lock file captures:
- Hardware identity (accelerator, CUDA version, CPU features)
- Platform information (OS, architecture)
- Python environment (version, packages)
- Library configurations

## Hardware-Aware Lock Files

The lock file includes hardware information to detect compatibility issues:

    %{
      "environment" => %{
        "hardware" => %{
          "accelerator" => "cuda",
          "cuda_version" => "12.1",
          "gpu_count" => 2,
          "cpu_features" => ["avx", "avx2"]
        },
        "platform" => %{
          "os" => "linux",
          "arch" => "x86_64"
        }
      }
    }

Use `SnakeBridge.Lock.Verifier` to verify compatibility.

# `build`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/lock.ex#L57)

```elixir
@spec build(SnakeBridge.Config.t()) :: map()
```

# `build_compatibility_section`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/lock.ex#L143)

```elixir
@spec build_compatibility_section(map()) :: map()
```

Builds the compatibility section with minimum requirements.

# `build_hardware_section`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/lock.ex#L96)

```elixir
@spec build_hardware_section() :: map()
```

Builds the hardware section for the lock file.

Returns a map with hardware identity including accelerator type,
CUDA version if available, GPU count, and CPU features.

# `build_platform_section`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/lock.ex#L123)

```elixir
@spec build_platform_section() :: map()
```

Builds the platform section for the lock file.

# `compute_packages_hash`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/lock.ex#L154)

```elixir
@spec compute_packages_hash(map()) :: String.t()
```

Deterministic hash from sorted package versions.

# `generator_hash`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/lock.ex#L266)

```elixir
@spec generator_hash() :: String.t()
```

Computes the generator hash from generator and adapter source contents.

# `get_package_metadata`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/lock.ex#L169)

```elixir
@spec get_package_metadata(SnakeBridge.Config.t()) :: map()
```

Gets package metadata for the lockfile.

# `load`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/lock.ex#L36)

```elixir
@spec load() :: map() | nil
```

# `update`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/lock.ex#L44)

```elixir
@spec update(SnakeBridge.Config.t()) :: :ok
```

# `verify_generator_unchanged?`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/lock.ex#L293)

```elixir
@spec verify_generator_unchanged?(map()) :: boolean()
```

Checks if the lock was generated with the current generator version.

# `write`
[🔗](https://github.com/nshkrdotcom/snakebridge/blob/v0.14.0/lib/snakebridge/lock.ex#L50)

```elixir
@spec write(map()) :: :ok
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
