README.md

# Anodex

Elixir bindings for [ANODE](https://github.com/psila-ai/anode) - a disk-resident approximate nearest neighbor (ANN) search system.

## Features

- **Disk-resident**: Handles datasets larger than RAM
- **Lock-free concurrent operations**: High throughput for mixed read/write workloads
- **Automatic sharding**: Manode automatically partitions data across shards
- **Formal recall guarantees**: Staleness tracking with theoretical recall bounds

## Installation

Add `anodex` to your dependencies in `mix.exs`:

```elixir
def deps do
  [
    {:anodex, "~> 0.1"}
  ]
end
```

## Usage

```elixir
# Create an index
opts = %Anodex.Options{
  dimension: 128,
  data_dir: "/var/lib/myapp/vectors",
  name: "embeddings",
  compaction_threshold: 100_000
}

{:ok, index} = Anodex.Manode.new(opts)

# Insert vectors
:ok = Anodex.Manode.insert(index, {1, embedding_vector})

# Search for nearest neighbors
{:ok, results} = Anodex.Manode.search(index, query_vector, 10)
# Returns [{distance, id}, ...]

# Shutdown (persists to disk)
:ok = Anodex.Manode.shutdown(index)
```

## Requirements

- Elixir >= 1.17
- Linux with io_uring support (kernel 5.1+)
- Rust toolchain only if building from source (`ANODEX_BUILD=true`)

## Releasing

1. **Bump version** in `mix.exs`:
   ```elixir
   @version "0.2.0"
   ```

2. **Push to master** — triggers precompiled NIF builds automatically.

3. **Wait for CI** — the "Build Precompiled NIFs" workflow uploads artifacts to [spiredb/anodex releases](https://github.com/spiredb/anodex/releases)

4. **Download checksums** and **publish to Hex**:
   ```bash
   mix rustler_precompiled.download Anodex.Native --all --print
   mix hex.publish
   ```

### GitHub Actions Workflows

| Workflow | Trigger | Purpose |
|----------|---------|---------|
| **CI** | Push/PR | Runs Rust and Elixir tests |
| **Build Precompiled NIFs** | Push to master (anodex/anode changes) | Builds NIFs for x86_64-linux, uploads to spiredb/anodex |
| **Publish to Hex.pm** | GitHub release or manual | Downloads checksums, publishes to Hex |

**Manual triggers** — all workflows support `workflow_dispatch`:
1. Go to Actions tab
2. Select workflow
3. Click "Run workflow"

## License

MIT