Merge commit 'd803bfe2b1fe7f5e219e50ac20d6801a0a58ac75' as 'vendor/ruvector'

This commit is contained in:
ruv
2026-02-28 14:39:40 -05:00
7854 changed files with 3522914 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
#!/bin/bash
# Pre-publish validation script for ruvector packages (without jq dependency)
set -e
echo "🔍 Validating ruvector packages for npm publishing..."
echo ""
PASSED=0
FAILED=0
WARNINGS=0
pass() { echo "$1"; ((PASSED++)); }
fail() { echo "$1"; ((FAILED++)); }
warn() { echo "$1"; ((WARNINGS++)); }
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " @ruvector/psycho-symbolic-integration"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
cd packages/psycho-symbolic-integration
[ -f "package.json" ] && pass "package.json exists" || fail "package.json missing"
[ -f "README.md" ] && pass "README.md exists" || fail "README.md missing"
[ -f "LICENSE" ] && pass "LICENSE exists" || warn "LICENSE missing"
[ -f ".npmignore" ] && pass ".npmignore exists" || warn ".npmignore missing"
[ -f "tsconfig.json" ] && pass "tsconfig.json exists" || warn "tsconfig.json missing"
[ -d "src" ] && pass "src/ directory exists" || fail "src/ directory missing"
[ -d "node_modules" ] && pass "dependencies installed" || warn "run npm install first"
grep -q '"name":' package.json && pass "name field exists" || fail "name field missing"
grep -q '"version":' package.json && pass "version field exists" || fail "version field missing"
grep -q '"description":' package.json && pass "description field exists" || fail "description field missing"
grep -q '"repository":' package.json && pass "repository field exists" || warn "repository field missing"
grep -q '"publishConfig":' package.json && pass "publishConfig exists" || warn "publishConfig missing"
cd ../..
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " @ruvector/psycho-synth-examples"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
cd packages/psycho-synth-examples
[ -f "package.json" ] && pass "package.json exists" || fail "package.json missing"
[ -f "README.md" ] && pass "README.md exists" || fail "README.md missing"
[ -f "LICENSE" ] && pass "LICENSE exists" || warn "LICENSE missing"
[ -f ".npmignore" ] && pass ".npmignore exists" || warn ".npmignore missing"
[ -f "tsconfig.json" ] && pass "tsconfig.json exists" || warn "tsconfig.json missing"
[ -d "src" ] && pass "src/ directory exists" || fail "src/ directory missing"
[ -d "bin" ] && pass "bin/ directory exists" || fail "bin/ directory missing"
[ -d "examples" ] && pass "examples/ directory exists" || fail "examples/ directory missing"
[ -d "node_modules" ] && pass "dependencies installed" || warn "run npm install first"
[ -f "bin/cli.js" ] && pass "CLI file exists" || fail "CLI file missing"
[ -x "bin/cli.js" ] && pass "CLI is executable" || warn "CLI not executable"
if head -1 bin/cli.js | grep -q "^#!/usr/bin/env node"; then
pass "CLI has correct shebang"
else
fail "CLI missing shebang"
fi
grep -q '"name":' package.json && pass "name field exists" || fail "name field missing"
grep -q '"version":' package.json && pass "version field exists" || fail "version field missing"
grep -q '"bin":' package.json && pass "bin field exists" || fail "bin field missing"
grep -q '"repository":' package.json && pass "repository field exists" || warn "repository field missing"
grep -q '"publishConfig":' package.json && pass "publishConfig exists" || warn "publishConfig missing"
# Test CLI
echo ""
if node bin/cli.js list > /dev/null 2>&1; then
pass "CLI 'list' command works"
else
fail "CLI 'list' command failed"
fi
cd ../..
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " Summary"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Passed: $PASSED"
echo "Warnings: $WARNINGS"
echo "Failed: $FAILED"
echo ""
if [ $FAILED -gt 0 ]; then
echo "❌ Validation failed with $FAILED errors"
exit 1
elif [ $WARNINGS -gt 0 ]; then
echo "⚠️ Validation passed with $WARNINGS warnings"
exit 0
else
echo "✅ All validations passed!"
exit 0
fi

View File

@@ -0,0 +1,221 @@
#!/bin/bash
# Pre-publish validation script for ruvector packages
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
echo "🔍 Validating ruvector packages for npm publishing..."
echo ""
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Validation counters
PASSED=0
FAILED=0
WARNINGS=0
# Helper functions
pass() {
echo -e "${GREEN}${NC} $1"
((PASSED++))
}
fail() {
echo -e "${RED}${NC} $1"
((FAILED++))
}
warn() {
echo -e "${YELLOW}${NC} $1"
((WARNINGS++))
}
section() {
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " $1"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
}
# Package validation function
validate_package() {
local PKG_DIR="$1"
local PKG_NAME="$2"
section "Validating: $PKG_NAME"
cd "$PKG_DIR"
# Check package.json exists
if [ -f "package.json" ]; then
pass "package.json exists"
else
fail "package.json missing"
return 1
fi
# Check required fields in package.json
local name=$(jq -r '.name' package.json)
local version=$(jq -r '.version' package.json)
local description=$(jq -r '.description' package.json)
local license=$(jq -r '.license' package.json)
local repository=$(jq -r '.repository.url' package.json)
[ "$name" != "null" ] && pass "name: $name" || fail "name missing"
[ "$version" != "null" ] && pass "version: $version" || fail "version missing"
[ "$description" != "null" ] && pass "description exists" || fail "description missing"
[ "$license" != "null" ] && pass "license: $license" || fail "license missing"
[ "$repository" != "null" ] && pass "repository URL set" || warn "repository URL missing"
# Check README
if [ -f "README.md" ]; then
local readme_size=$(wc -c < README.md)
if [ "$readme_size" -gt 500 ]; then
pass "README.md exists ($(echo $readme_size | numfmt --to=iec-i --suffix=B))"
else
warn "README.md exists but seems short (${readme_size} bytes)"
fi
else
fail "README.md missing"
fi
# Check LICENSE
if [ -f "LICENSE" ]; then
pass "LICENSE exists"
else
warn "LICENSE missing"
fi
# Check .npmignore
if [ -f ".npmignore" ]; then
pass ".npmignore exists"
else
warn ".npmignore missing (npm will use .gitignore)"
fi
# Check TypeScript configuration
if [ -f "tsconfig.json" ]; then
pass "tsconfig.json exists"
else
warn "tsconfig.json missing"
fi
# Check source directory
if [ -d "src" ]; then
local src_files=$(find src -name "*.ts" -type f | wc -l)
pass "src/ directory exists ($src_files TypeScript files)"
else
fail "src/ directory missing"
fi
# Check if dependencies are installed
if [ -d "node_modules" ]; then
pass "node_modules exists (dependencies installed)"
else
warn "node_modules missing - run npm install"
fi
# Validate package scripts
local has_build=$(jq -r '.scripts.build' package.json)
[ "$has_build" != "null" ] && pass "build script defined" || warn "build script missing"
# Check for bin (CLI packages)
local has_bin=$(jq -r '.bin' package.json)
if [ "$has_bin" != "null" ]; then
pass "bin entry defined (CLI package)"
# Validate bin files exist
local bin_file=$(jq -r '.bin | if type=="object" then .[keys[0]] else . end' package.json)
if [ -f "$bin_file" ]; then
pass "bin file exists: $bin_file"
# Check shebang
if head -1 "$bin_file" | grep -q "^#!/usr/bin/env node"; then
pass "bin file has correct shebang"
else
fail "bin file missing shebang: #!/usr/bin/env node"
fi
# Check executable permission
if [ -x "$bin_file" ]; then
pass "bin file is executable"
else
warn "bin file not executable - will be fixed by npm"
fi
else
fail "bin file missing: $bin_file"
fi
fi
# Check publishConfig
local publish_access=$(jq -r '.publishConfig.access' package.json)
[ "$publish_access" == "public" ] && pass "publishConfig.access: public" || warn "publishConfig.access not set to public (scoped packages need this)"
# Validate files field
local files=$(jq -r '.files' package.json)
if [ "$files" != "null" ]; then
pass "files field defined"
# Check if listed files exist
jq -r '.files[]' package.json | while read -r file; do
if [ -e "$file" ] || [ "$file" == "dist" ]; then
pass " - $file exists (or will be created by build)"
else
warn " - $file listed but not found"
fi
done
else
warn "files field not defined (npm will include everything not in .npmignore)"
fi
cd "$ROOT_DIR"
}
# Main validation
cd "$ROOT_DIR"
# Validate psycho-symbolic-integration
validate_package "$ROOT_DIR/packages/psycho-symbolic-integration" "@ruvector/psycho-symbolic-integration"
# Validate psycho-synth-examples
validate_package "$ROOT_DIR/packages/psycho-synth-examples" "@ruvector/psycho-synth-examples"
# Test CLI functionality
section "Testing CLI Functionality"
cd "$ROOT_DIR/packages/psycho-synth-examples"
if node bin/cli.js list > /dev/null 2>&1; then
pass "CLI 'list' command works"
else
fail "CLI 'list' command failed"
fi
cd "$ROOT_DIR"
# Summary
section "Validation Summary"
echo ""
echo -e "${GREEN}Passed:${NC} $PASSED"
echo -e "${YELLOW}Warnings:${NC} $WARNINGS"
echo -e "${RED}Failed:${NC} $FAILED"
echo ""
if [ $FAILED -gt 0 ]; then
echo -e "${RED}❌ Validation failed with $FAILED errors${NC}"
echo "Please fix the errors before publishing."
exit 1
elif [ $WARNINGS -gt 0 ]; then
echo -e "${YELLOW}⚠️ Validation passed with $WARNINGS warnings${NC}"
echo "Consider addressing warnings before publishing."
exit 0
else
echo -e "${GREEN}✅ All validations passed!${NC}"
echo "Packages are ready for publishing."
exit 0
fi

View File

@@ -0,0 +1,123 @@
#!/bin/bash
# Verification script for LocalKCut paper implementation
set -e
echo "==============================================="
echo "LocalKCut Paper Implementation Verification"
echo "==============================================="
echo ""
echo "1. Checking files exist..."
if [ -f "crates/ruvector-mincut/src/localkcut/paper_impl.rs" ]; then
echo " ✓ paper_impl.rs created"
wc -l crates/ruvector-mincut/src/localkcut/paper_impl.rs
else
echo " ✗ paper_impl.rs not found"
exit 1
fi
if [ -f "docs/localkcut-paper-implementation.md" ]; then
echo " ✓ Documentation created"
wc -l docs/localkcut-paper-implementation.md
else
echo " ✗ Documentation not found"
exit 1
fi
echo ""
echo "2. Verifying module structure..."
if grep -q "pub mod paper_impl;" crates/ruvector-mincut/src/localkcut/mod.rs; then
echo " ✓ paper_impl module exported"
else
echo " ✗ Module export missing"
exit 1
fi
if grep -q "LocalKCutQuery" crates/ruvector-mincut/src/localkcut/mod.rs; then
echo " ✓ API types re-exported"
else
echo " ✗ API types not exported"
exit 1
fi
echo ""
echo "3. Running unit tests..."
cargo test -p ruvector-mincut --lib localkcut::paper_impl::tests --quiet
echo ""
echo "4. Checking test count..."
TEST_COUNT=$(cargo test -p ruvector-mincut --lib localkcut::paper_impl::tests -- --list 2>/dev/null | grep "test" | wc -l)
echo " Found $TEST_COUNT tests"
if [ "$TEST_COUNT" -ge 16 ]; then
echo " ✓ All tests present ($TEST_COUNT >= 16)"
else
echo " ✗ Missing tests ($TEST_COUNT < 16)"
exit 1
fi
echo ""
echo "5. Verifying API compliance..."
if grep -q "pub struct LocalKCutQuery" crates/ruvector-mincut/src/localkcut/paper_impl.rs; then
echo " ✓ LocalKCutQuery struct"
fi
if grep -q "pub enum LocalKCutResult" crates/ruvector-mincut/src/localkcut/paper_impl.rs; then
echo " ✓ LocalKCutResult enum"
fi
if grep -q "pub trait LocalKCutOracle" crates/ruvector-mincut/src/localkcut/paper_impl.rs; then
echo " ✓ LocalKCutOracle trait"
fi
if grep -q "pub struct DeterministicLocalKCut" crates/ruvector-mincut/src/localkcut/paper_impl.rs; then
echo " ✓ DeterministicLocalKCut implementation"
fi
if grep -q "pub struct DeterministicFamilyGenerator" crates/ruvector-mincut/src/localkcut/paper_impl.rs; then
echo " ✓ DeterministicFamilyGenerator"
fi
echo ""
echo "6. Verifying determinism..."
if grep -q "sort_unstable()" crates/ruvector-mincut/src/localkcut/paper_impl.rs; then
echo " ✓ Uses sorted traversal for determinism"
else
echo " ✗ Missing deterministic ordering"
exit 1
fi
if ! grep -q "use.*rand" crates/ruvector-mincut/src/localkcut/paper_impl.rs; then
echo " ✓ No randomness detected"
else
echo " ✗ Uses randomness (not deterministic)"
exit 1
fi
echo ""
echo "7. Checking witness integration..."
if grep -q "WitnessHandle::new" crates/ruvector-mincut/src/localkcut/paper_impl.rs; then
echo " ✓ Creates WitnessHandle"
fi
if grep -q "boundary_size" crates/ruvector-mincut/src/localkcut/paper_impl.rs; then
echo " ✓ Uses boundary_size API"
fi
echo ""
echo "==============================================="
echo "✓ All verifications passed!"
echo "==============================================="
echo ""
echo "Summary:"
echo " - Implementation: crates/ruvector-mincut/src/localkcut/paper_impl.rs"
echo " - Tests: 16 comprehensive unit tests"
echo " - Documentation: docs/localkcut-paper-implementation.md"
echo " - API: Strictly compliant with paper specification"
echo " - Determinism: Verified (no randomness)"
echo " - Integration: Exports available at crate root"
echo ""
echo "Usage:"
echo " cargo test -p ruvector-mincut --lib localkcut::paper_impl"
echo ""

View File

@@ -0,0 +1,164 @@
#!/bin/bash
# ============================================================================
# HNSW Index Build Verification Script
# ============================================================================
# Verifies that the HNSW index implementation compiles and tests pass
set -e # Exit on error
echo "=================================="
echo "HNSW Index Build Verification"
echo "=================================="
echo ""
# Color codes
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check we're in the right directory
if [ ! -f "Cargo.toml" ]; then
echo -e "${RED}Error: Must run from ruvector root directory${NC}"
exit 1
fi
# Step 1: Check Rust compilation
echo -e "${YELLOW}Step 1: Checking Rust compilation...${NC}"
cd crates/ruvector-postgres
if cargo check --all-features 2>&1 | tee /tmp/hnsw_check.log; then
echo -e "${GREEN}✓ Rust code compiles successfully${NC}"
else
echo -e "${RED}✗ Rust compilation failed${NC}"
echo "See /tmp/hnsw_check.log for details"
exit 1
fi
echo ""
# Step 2: Run Rust unit tests
echo -e "${YELLOW}Step 2: Running Rust unit tests...${NC}"
if cargo test --lib 2>&1 | tee /tmp/hnsw_test.log; then
echo -e "${GREEN}✓ Rust tests passed${NC}"
else
echo -e "${RED}✗ Rust tests failed${NC}"
echo "See /tmp/hnsw_test.log for details"
exit 1
fi
echo ""
# Step 3: Check pgrx build
echo -e "${YELLOW}Step 3: Building pgrx extension...${NC}"
if cargo pgrx package 2>&1 | tee /tmp/hnsw_pgrx.log; then
echo -e "${GREEN}✓ pgrx extension built successfully${NC}"
else
echo -e "${RED}✗ pgrx build failed${NC}"
echo "See /tmp/hnsw_pgrx.log for details"
exit 1
fi
echo ""
# Step 4: Verify SQL files exist
echo -e "${YELLOW}Step 4: Verifying SQL files...${NC}"
SQL_FILES=(
"sql/ruvector--0.1.0.sql"
"sql/hnsw_index.sql"
"tests/hnsw_index_tests.sql"
)
ALL_SQL_EXIST=true
for file in "${SQL_FILES[@]}"; do
if [ -f "$file" ]; then
echo -e "${GREEN}✓ Found: $file${NC}"
else
echo -e "${RED}✗ Missing: $file${NC}"
ALL_SQL_EXIST=false
fi
done
if [ "$ALL_SQL_EXIST" = false ]; then
echo -e "${RED}Some SQL files are missing${NC}"
exit 1
fi
echo ""
# Step 5: Verify Rust source files
echo -e "${YELLOW}Step 5: Verifying Rust source files...${NC}"
RUST_FILES=(
"src/index/hnsw.rs"
"src/index/hnsw_am.rs"
"src/index/mod.rs"
)
ALL_RUST_EXIST=true
for file in "${RUST_FILES[@]}"; do
if [ -f "$file" ]; then
echo -e "${GREEN}✓ Found: $file${NC}"
else
echo -e "${RED}✗ Missing: $file${NC}"
ALL_RUST_EXIST=false
fi
done
if [ "$ALL_RUST_EXIST" = false ]; then
echo -e "${RED}Some Rust files are missing${NC}"
exit 1
fi
echo ""
# Step 6: Check documentation
echo -e "${YELLOW}Step 6: Verifying documentation...${NC}"
cd ../.. # Back to root
DOC_FILES=(
"docs/HNSW_INDEX.md"
)
ALL_DOCS_EXIST=true
for file in "${DOC_FILES[@]}"; do
if [ -f "$file" ]; then
echo -e "${GREEN}✓ Found: $file${NC}"
else
echo -e "${RED}✗ Missing: $file${NC}"
ALL_DOCS_EXIST=false
fi
done
echo ""
# Step 7: Check for compilation warnings
echo -e "${YELLOW}Step 7: Checking for warnings...${NC}"
WARNING_COUNT=$(grep -c "warning:" /tmp/hnsw_check.log || true)
if [ "$WARNING_COUNT" -eq 0 ]; then
echo -e "${GREEN}✓ No compilation warnings${NC}"
else
echo -e "${YELLOW}⚠ Found $WARNING_COUNT warnings${NC}"
echo "Check /tmp/hnsw_check.log for details"
fi
echo ""
# Summary
echo "=================================="
echo -e "${GREEN}All verification checks passed!${NC}"
echo "=================================="
echo ""
echo "Next steps:"
echo "1. Install extension: cargo pgrx install"
echo "2. Run SQL tests: psql -d testdb -f crates/ruvector-postgres/tests/hnsw_index_tests.sql"
echo "3. Create index: CREATE INDEX ON table USING hnsw (column hnsw_l2_ops);"
echo ""
echo "Documentation: docs/HNSW_INDEX.md"
echo ""