# API-003: Individual chia-sdk-* Crates

> **Authoritative requirement:** [API-003](../NORMATIVE.md#API-003)
> **Verification:** [VERIFICATION.md](../VERIFICATION.md)
> **Tracking:** [TRACKING.yaml](../TRACKING.yaml)
> **Spec reference:** [SPEC.md](../../../../resources/SPEC.md) — Section 4.2

---

## Summary

`dig-clvm` MUST depend on the individual `chia-sdk-*` crates (`chia-sdk-types`, `chia-sdk-driver`, `chia-sdk-coinset`) rather than the `chia-wallet-sdk` umbrella crate. The umbrella crate re-exports these sub-crates but also pulls in RPC clients, wallet utilities, and potentially async networking dependencies that violate the pure-computation boundary established by [API-002](API-002.md).

By depending on the individual crates, `dig-clvm` gets precisely the functionality it needs -- spend construction (`chia-sdk-driver`), condition types (`chia-sdk-types`), and coin records (`chia-sdk-coinset`) -- without transitive dependencies on wallet-specific infrastructure. This is the same principle that drives Chia L1's separation between the core Rust crates and the Python wallet layer.

The three required SDK crates and their versions are pinned in `Cargo.toml` alongside their specific feature requirements. Only `chia-sdk-driver` requires a feature flag (`action-layer`) for the CHIP-0050 action-based spending pattern used in modern puzzle construction.

---

## Specification

### Required Individual Dependencies

The following three `chia-sdk-*` crates MUST appear in `[dependencies]`:

```toml
chia-sdk-types = "0.30"
chia-sdk-driver = { version = "0.30", features = ["action-layer"] }
chia-sdk-coinset = "0.30"
```

### Banned Umbrella Dependency

The following crate MUST NOT appear in `[dependencies]`:

```toml
# BANNED - pulls in RPC clients, wallet utilities, async deps
chia-wallet-sdk = "..."
```

### Rationale for Each Crate

| Crate | Purpose in dig-clvm | Items Re-exported |
|---|---|---|
| `chia-sdk-types` | Condition types, puzzle module trait, run_puzzle | `Condition`, `Conditions`, `Mod` |
| `chia-sdk-driver` | Spend construction, puzzle drivers, layer system | `SpendContext`, `Layer`, `Spend`, `SpendWithConditions`, `Puzzle`, `DriverError` |
| `chia-sdk-coinset` | Coin record type for state tracking | `CoinRecord` |

### Feature Flags

- `chia-sdk-driver` MUST be compiled with the `action-layer` feature enabled. This feature provides the CHIP-0050 action-based spending pattern without introducing any async or network dependencies.
- No other optional features should be enabled unless specifically needed and verified to not violate [API-002](API-002.md).

---

## Acceptance Criteria

- [ ] `Cargo.toml` lists `chia-sdk-types`, `chia-sdk-driver`, and `chia-sdk-coinset` as individual dependencies
- [ ] `Cargo.toml` does NOT list `chia-wallet-sdk` in any form
- [ ] `chia-sdk-driver` is configured with `features = ["action-layer"]`
- [ ] All three crates are pinned to compatible versions (currently `0.30`)
- [ ] No transitive dependency through these crates introduces async/IO/storage deps (verified via `cargo tree`)

---

## Implementation Notes

- The `chia-sdk-*` crates follow semver. Version `0.30` is the current target. When upgrading, ensure the new versions maintain the same pure-computation contract.
- The `action-layer` feature on `chia-sdk-driver` enables `ActionLayer` and related types for CHIP-0050 compatibility. This is a compile-time-only feature with no runtime or I/O implications.
- `chia-sdk-test` (the simulator) belongs in `[dev-dependencies]` only, not in `[dependencies]`. It is not part of this requirement.
- If `chia-wallet-sdk` is ever restructured to be a pure re-export without additional transitive deps, this requirement should be re-evaluated. Until then, individual crates are mandatory.

---

## Verification

### Test Plan

1. **Cargo.toml inspection**:
   - Open `dig-clvm/Cargo.toml` and verify the three individual crates are present.
   - Verify `chia-wallet-sdk` does not appear anywhere in the file.

2. **Feature flag verification**:
   - Confirm `chia-sdk-driver` entry includes `features = ["action-layer"]`.

3. **Transitive dependency check**:
   ```bash
   cargo tree -p dig-clvm -i chia-wallet-sdk 2>&1
   ```
   - MUST report that `chia-wallet-sdk` is not in the dependency graph.

4. **Version compatibility check**:
   - Verify all three `chia-sdk-*` crates are at compatible versions (same minor version).
   - Run `cargo build -p dig-clvm` to confirm no version conflicts.

---

## Source Citations

- [SPEC.md Section 4.2](../../../../resources/SPEC.md) — Dependencies listing with individual SDK crates
- [SPEC.md Section 2.7-2.8, 2.11](../../../../resources/SPEC.md) — Individual SDK crate descriptions

---

## References

- [API-001](API-001.md) — Re-exports sourced from these individual crates
- [API-002](API-002.md) — No async/IO deps (motivation for avoiding umbrella)
- [API-004](API-004.md) — No storage access (complementary constraint)
