|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Build and Test Commands |
| 6 | + |
| 7 | +### Task CLI |
| 8 | + |
| 9 | +Use the `task` CLI — read Taskfile.yaml for all available tasks and to understand how they work. |
| 10 | + |
| 11 | +### SBT |
| 12 | + |
| 13 | +The underlying tool for most tasks is `sbt`, specifically `sbt -client` (thin client connecting to a persistent sbt server). |
| 14 | +Sometimes you need to use it directly rather than using |
| 15 | + |
| 16 | +**Running a single test class:** |
| 17 | +```bash |
| 18 | +sbt -client "elastiknn-plugin/testOnly com.klibisz.elastiknn.query.SomeSpec" |
| 19 | +``` |
| 20 | + |
| 21 | +### Integration Testing |
| 22 | + |
| 23 | +Integration tests require a Docker cluster (see `dockerRunTestingCluster` / `dockerStopTestingCluster` tasks in Taskfile.yaml). |
| 24 | + |
| 25 | +### Java Version |
| 26 | + |
| 27 | +The project uses Java 21 (see `.tool-versions`). Manage via asdf. Building with a newer JDK will embed that version in `plugin-descriptor.properties`, causing the plugin install to fail in the Docker container (which runs ES's bundled JDK). |
| 28 | + |
| 29 | +## Project Structure |
| 30 | + |
| 31 | +The project has seven SBT subprojects (Scala 3.3.6): |
| 32 | + |
| 33 | +| Module | Role | |
| 34 | +|--------|------| |
| 35 | +| `elastiknn-api4s` | API types: (`Vec`, `Mapping`, `NearestNeighborsQuery`, etc.) XContent serialization | |
| 36 | +| `elastiknn-models` | LSH model implementations and vector similarity math (Java + Panama SIMD) | |
| 37 | +| `elastiknn-lucene` | Custom Lucene queries (`MatchHashesAndScoreQuery`) and field types | |
| 38 | +| `elastiknn-plugin` | ES plugin: mappers, query builders, score functions | |
| 39 | +| `elastiknn-plugin-integration-tests` | Full end-to-end tests against a live ES cluster | |
| 40 | +| `elastiknn-client-elastic4s` | Scala client library using elastic4s | |
| 41 | +| `elastiknn-jmh-benchmarks` | JMH microbenchmarks | |
| 42 | + |
| 43 | +Dependency order: `api4s` ← `models` ← `lucene` ← `plugin` ← `integration-tests` |
| 44 | + |
| 45 | +## Key Version Variables (build.sbt) |
| 46 | + |
| 47 | +```scala |
| 48 | +ElasticsearchVersion // must match docker/Dockerfile and version file |
| 49 | +LuceneVersion // must match the Lucene bundled in the ES release |
| 50 | +ElastiknnVersion // read from the `version` file (e.g. 8.18.4.0) |
| 51 | +``` |
| 52 | + |
| 53 | +When upgrading ES, update all four: `build.sbt`, `docker/Dockerfile`, `docs/pages/installation.md`, and `version`. Also check whether the bundled Lucene version changed (`sbt elastiknn-plugin/dependencyTree | grep lucene`). |
| 54 | + |
| 55 | +## Dependency Upgrades |
| 56 | + |
| 57 | +Use `/upgrade-elasticsearch` to perform an Elasticsearch upgrade end-to-end. |
| 58 | + |
| 59 | +Other JVM dependencies are mostly handled by Scala Steward via automated PRs (see git log for the pattern). |
| 60 | + |
| 61 | +## SIMD / Panama Vector API |
| 62 | + |
| 63 | +`PanamaFloatVectorOps` uses `jdk.incubator.vector` for SIMD-accelerated dot product, cosine, L1, and L2 computations. It is enabled at runtime via the `elastiknn.jdk-incubator-vector.enabled` setting. The sbt server and ES container both need `--add-modules jdk.incubator.vector` (already configured in `.sbtopts` and `build.sbt`). |
| 64 | + |
| 65 | +SIMD `reduceLanes(ADD)` can produce slightly different floating-point results before vs. after JIT compilation — relevant when writing determinism tests. |
| 66 | + |
| 67 | +## CI |
| 68 | + |
| 69 | +`.github/workflows/ci.yaml` runs: lint → compile → assemble → unit tests → start Docker cluster → integration tests. Scala compiler is strict (`CiMode`) when `CI=true`; locally it uses `DevMode` (relaxed). |
0 commit comments