๐ค Contributing¶
We'd love your help making Spector even better! Whether you're fixing a bug, adding a feature, improving docs, or optimizing performance โ every contribution matters. This page covers everything you need to get started.
๐ Development Setup¶
๐ Prerequisites¶
| Tool | Version | Notes |
|---|---|---|
| โ JDK | 25+ | OpenJDK with Vector API incubator |
| ๐ฆ Maven | 3.9+ | Multi-module reactor build |
| ๐ง Git | 2.40+ | Version control |
๐๏ธ First-Time Setup¶
# Fork and clone
git clone https://github.com/<your-username>/spector.git
cd spector
# Verify JDK
java -version # Should show 25+
# Build the project
mvn clean compile
# Run the full test suite (316+ tests)
mvn test
# Verify SIMD support
java --add-modules jdk.incubator.vector -cp spector-core/target/classes \
com.spectrayan.spector.core.SimdCapability
Tip
The full build takes ~2 minutes. Use mvn test -pl spector-core to test a single module during development.
๐ฆ Module Structure¶
graph LR
subgraph "๐ฌ Foundation"
core["spector-core<br/>SIMD kernels"]
commons["spector-commons<br/>Chunkers, readers"]
storage["spector-storage<br/>Off-heap stores"]
end
subgraph "๐ Search"
index["spector-index<br/>HNSW, IVF-PQ, BM25"]
query["spector-query<br/>Hybrid + RRF"]
end
subgraph "๐ง Intelligence"
embedapi["spector-embed-api<br/>Embedding SPI"]
embedollama["spector-embed-ollama<br/>Ollama provider"]
gpu["spector-gpu<br/>CUDA via Panama"]
end
subgraph "โก Applications"
engine["spector-engine<br/>Unified facade"]
server["spector-node<br/>REST API"]
cluster["spector-node<br/>Distributed gRPC"]
cli["spector-cli<br/>CLI tool"]
client["spector-client<br/>Java SDK"]
spring["spector-spring<br/>Spring AI"]
end
subgraph "๐ Quality"
bench["spector-bench<br/>JMH benchmarks"]
end
๐งช Running Tests¶
# Full suite
mvn test
# Single module
mvn test -pl spector-core
# Single test class
mvn test -pl spector-core -Dtest=DotProductTest
# With JMH benchmarks
mvn -pl spector-bench exec:java
๐ Code Style¶
Java Conventions¶
| Rule | Details |
|---|---|
| Java 25 features | Records, sealed classes, pattern matching, switch expressions |
| Vector API | Always use FloatVector.SPECIES_PREFERRED, never hardcode lanes |
| Panama FFM | Arena.ofShared() for concurrent, Arena.ofConfined() for single-thread |
| Virtual Threads | ReentrantLock instead of synchronized (avoids pinning) |
| Testing | JUnit 5 + AssertJ for all new features |
| Javadoc | Required on all public classes and methods |
โก Performance Rules¶
-
No allocations in hot paths โ Reuse buffers, use slice-based APIs
-
Branchless SIMD โ Use
VectorMaskfor tail handling, no scalar fallback -
Benchmark before/after โ Performance PRs must include JMH results
๐๏ธ Architecture Rules¶
-
Respect module boundaries โ Follow the dependency graph, no circular dependencies
-
Interface-first โ Add interfaces before implementations
-
Zero-copy โ Prefer
MemorySegmentslices over array copies
๐ฟ Branch Naming¶
feat/add-quantization-support
fix/hnsw-concurrent-insert-race
perf/simd-avx512-unroll-loop
refactor/storage-arena-lifecycle
docs/api-usage-examples
๐ฌ Commit Messages¶
Follow Conventional Commits:
feat(core): add AVX-512 double-pump dot product kernel
fix(index): prevent HNSW neighbor list corruption under concurrent insert
perf(storage): use bulk MemorySegment.copy for vector reads
refactor(query): extract RRF into standalone utility class
docs: add benchmark results to README
test(index): add property tests for HNSW persistence round-trip
| Type | Purpose |
|---|---|
feat |
New feature |
fix |
Bug fix |
perf |
Performance improvement |
refactor |
Code restructuring (no behavior change) |
docs |
Documentation only |
test |
Adding or updating tests |
chore |
Build, CI, tooling changes |
โ Testing Requirements¶
All new features require tests. The project uses:
| Framework | Purpose |
|---|---|
| JUnit 5 | Unit tests |
| AssertJ | Fluent assertions |
| jqwik | Property-based tests |
| JMH | Performance benchmarks |
Test Categories¶
| Type | When Required | Location |
|---|---|---|
| Unit tests | All changes | src/test/java/ in each module |
| Property tests | Algorithm changes | src/test/java/ with @Property |
| Integration tests | Cross-module changes | spector-engine/src/test/ |
| Benchmarks | Performance PRs | spector-bench/src/main/ |
Property-Based Tests Example¶
@Property(tries = 100)
void hnswPersistenceRoundTrip(@ForAll @Size(min=10, max=1000) List<float[]> vectors) {
// Build index, persist, reload, verify identical search results
}
๐ Pull Request Process¶
- Create a branch from
mainwith appropriate naming - Make changes with tests
- Ensure all tests pass โ
mvn test - Fill out the PR template
- Link related issues โ
Closes #123orFixes #456 - One approval required from a maintainer
- Squash merge to keep history clean
โ PR Checklist¶
-
Code follows the project's coding standards
-
Tests added/updated for the change
-
Javadoc updated for public API changes
-
No hardcoded secrets or credentials
-
Commit messages follow Conventional Commits
-
JMH benchmarks included (if performance-related)
-
No circular module dependencies introduced
๐ Reporting Issues¶
Bug Reports¶
Use the Bug Report template:
-
Steps to reproduce
-
Expected vs actual behavior
-
JDK version and SIMD capability output
-
Relevant logs or stack traces
๐ก Feature Requests¶
Use the Feature Request template:
-
Problem you're solving
-
Proposed solution
-
Alternatives considered
๐ฌ Getting Help¶
| Channel | Use For |
|---|---|
| GitHub Discussions | General questions |
| GitHub Issues | Bug reports |
| SECURITY.md | Security vulnerabilities |
| developer@spectrayan.com | Direct contact |
๐ See Also¶
-
Architecture Overview โ System design
-
Core Concepts โ Algorithms and data structures
-
Performance Tuning โ Benchmark methodology