ruvector/scripts
rUv 425d5ca9d2
feat(openjev): OpenJev pipeline — Rust trainer, vast.ai runner, Jev-parity bench, calibration API (ADR-008); v1 results (#1029)
* feat(gpu-runner): budget-capped vast.ai launcher with auto-destroy

Rust CLI for OpenJev training runs on vast.ai. Hard --max-usd/--max-hours
with a watchdog, idempotent destroy on success/failure/timeout/signal/panic,
verified-host offer filters re-checked client-side, digest-pinned images,
SHA-pinned git checkout, and credential-free uploads via per-object signed
PUT URLs minted by impersonating a keyless objectCreator SA. JSONL audit log,
--dry-run and reap.

Co-Authored-By: claude-flow <ruv@ruv.net>

* docs(openjev): ADR-007 OpenJev model + v0 implementation plan

Open-weight Jev-contract model for @ruvector/typesafe: bge-small fine-tuned
in candle, weights transplanted into the pinned ONNX graph (ort parity
>= 0.9999 cosine), calibrated on the existing slice. Pre-registered claims
use the campaign's paired sequential test (superior to Jev baseline,
non-inferior to Jev champion), a template-memorisation slice, a hard
train/test hash-leakage abort, and a within-2pp target vs published
Banking77/CLINC150 SOTA.

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(gpu-runner): pass --region to sign-url

The keyless signer SA only holds objectCreator, so gcloud cannot auto-detect
the bucket region (needs storage.buckets.get). Pass it explicitly
(--bucket-region, default us-central1) instead of widening the SA.

Co-Authored-By: claude-flow <ruv@ruv.net>

* feat(typesafe/bench): OpenJev v0 harness — leakage, --model-dir, --no-test, per-item records, vs-jev

ADR-007 plan Step 1 (bench side only; the Rust trainer lives on feat/openjev-train).

- lib/norm.mjs: norm/sha256Norm (NFKC -> lowercase -> [^\p{L}\p{N}]+ -> " " -> trim),
  52 golden vectors in bench/test/norm-golden.json, cross-checked against a Rust
  reference (unicode-normalization + regex) — the trainer's contract.
- lib/leakage.mjs: Assertion B. train-text-hashes.txt parsed strictly; run.mjs and
  optimize.mjs refuse to score (exit 3) when any held-out text hash (tickets test +
  transfer + calibration; public test) is in the model's train hashes.
- lib/model-dir.mjs: --model-dir/--manifest resolve ONE sha256-verified entry
  (staged manifest or synthesized for a bare dir), passed inline to the engine
  (no first-entry fallback) and recorded as embedder_model in receipts.
- run.mjs: --no-test (validation + transfer only, no Jev replay), --train-hashes,
  --emit-records; local receipts carry item_records per split.
- optimize.mjs: --model-dir, --manifest, --train-hashes, --no-test (test rows
  withheld, test fields null); main() exported with an injectable binding.
- lib/paired.mjs: JS port of PairedSequentialTest (alpha 0.05, lambda 0.5, f32
  rounding) proven against Rust-emitted wealth paths (bench/test/paired-golden.json).
- vs-jev.mjs: superior / non-inferior / loses tiers vs Jev baseline and champion,
  lexical id order, on full / novel (119) / template (31) slices.
- lib/novel-slice.mjs + fixtures/novel-slice-2026-09-26.json, pinned under
  HASHES.json `derived` (hash-fixtures.mjs), leaving the release fixture pin intact.
- fetch-models.mjs: OpenJev download map derived from an immutable HF revision,
  openjevManifestEntry() shape, --add-openjev <commit> bootstrap; importable.

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(typesafe/bench): path-free OpenJev receipt blocks, honest arms under --no-test, per-arm missing models

- embedder_model / leakage record file names + sha256s, never absolute paths.
- run.mjs --no-test no longer lists the skipped jev arm in receipt.arms.
- optimize.mjs: an unfetched model is a per-arm error again (as before the
  model-dir refactor); unpinned/mismatched models and leaks stay fatal.

Verified: local-arm metrics of the release ONNX command are identical before and
after the harness changes (test/validation/transfer, latency excluded).

Co-Authored-By: claude-flow <ruv@ruv.net>

* feat(openjev): Rust trainer crate ruvector-typesafe-train (ADR-007 v0)

New workspace crate + `openjev` CLI implementing the OpenJev v0 training
pipeline from docs/research/openjev/v0-plan.md, Rust only:

- prep: rebuilds the bench's exact splits (tickets assignSplit +
  excludeHeldOutText; Banking77/CLINC150/HWU64 parsing and ids) from the
  frozen fixture and sha256-pinned public files; writes train/val jsonl,
  labels.json, heldout-hashes.txt, data-manifest.json. Cross-checked
  against the JS loaders: 0 mismatched rows, 136/150 tickets train/val.
- Assertion A: held-out hashes recomputed from sources before the first
  step; any train/val collision aborts with exit 3 (planted-collision
  tests, unit + real data). norm() passes all 52 bench golden vectors.
- train: own BERT forward (candle-nn 0.9.2 fused LayerNorm/softmax have no
  backward), SupCon over P x K batches with label descriptions as
  positives, cosine heads (dept/urgent/frustration + 3 public), soft
  ambiguous targets, label smoothing, CLINC outlier exposure, AdamW with
  param groups + global-norm clip, warmup/linear decay, early stopping.
- transplant: value-matches all 197 float initializers to the ORIGINAL
  BAAI safetensors (72 anonymous transposed MatMuls cross-checked against
  their consuming node names), requires a bijection, patches payload
  bytes in place; identity transplant is byte-identical to the template.
- parity: engine OrtEmbedder on the new ONNX vs candle, cosine >= 0.9999
  per probe + identical engine department decisions.
- stage: bench model-dir layout with pinned manifest.
- scripts/openjev/vast-train.sh for ruvector-gpu-runner (CUDA build,
  fetch, prep, train, transplant, parity, SHA256SUMS into RVGR_ARTIFACT_DIR).

candle/cudarc/tract/ort/prost are the versions already in Cargo.lock; the
lock change is only the new crate entry. CUDA is an opt-in feature.

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(openjev-train): bound GPU memory — detached AdamW moments, graph-free eval, pool trim

Found on the local RTX 5080 end-to-end runs:
- AdamW moments were built from gradient tensors that carry backprop
  history, chaining every step's graph (~40 MB/step, OOM at ~400 steps).
  Gradients, moments and theta are now detached (regression test).
- Evaluation ran on Var-backed weights and recorded a full autograd graph
  per batch. `model::frozen_view` shares the Vars' storage without
  tracking (reflects optimizer updates via Var::set; tested); parity uses
  it too.
- cudarc allocates from the device's default stream-ordered pool; varying
  batch shapes plus full-validation passes ratcheted the reserve past
  16 GB at ~1500 v0 steps. `gpu::trim` syncs and cuMemPoolTrimTo(0)s after
  every eval and every 25 steps, logging device memory to curves.jsonl.
  Full v0 config now peaks ~10 GB and trims back to 3.4-4.9 GB, flat.

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(openjev-train): never train on label descriptions that equal a test text

Checking the shipped train-text-hashes.txt against ALL held-out hashes (not
just tickets) found 12 collisions: humanised intent names used as SupCon
extra positives are verbatim public test utterances (CLINC150 goodbye,
directions, time, what_is_your_name, ...; Banking77 pending_transfer; HWU64
play_audiobook). They received gradients with their true label, and the
bench's Assertion B would refuse every public suite (exit 3).

- leakage::colliding_descriptions; prep-check and prep record them in
  leakage-report.json (`dropped_descriptions`); train excludes them from
  the SupCon positives and from train-text-hashes.txt (which now lists
  exactly the texts that produced gradients). Real-data test pins 12.
- The per-run leakage-report.json now carries prep's dropped_duplicates
  (was 0) so the model card can quote it verbatim.
- parity reports cosines in f64 (min 0.9999999999993 on the e2e run).

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(openjev): vast-train.sh installs libssl-dev (ort-sys build needs openssl-sys)

Found by running the script in the runner's pinned nvidia/cuda:12.4.1-devel
image: the ort-sys build script downloads onnxruntime via ureq/native-tls.

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(openjev): vast-train.sh requires an Ubuntu 24.04 CUDA image (glibc >= 2.38)

ort 2.0.0-rc.13's prebuilt static onnxruntime (engine native path, used by
parity) references __isoc23_strtol and GCC 13 libstdc++ symbols, so linking
fails in the runner's default cuda:12.4.1-devel-ubuntu22.04 (glibc 2.35).
Found by running the script in that pinned image. The script now refuses in
seconds on glibc < 2.38 and documents the pinned replacement image
nvidia/cuda:12.6.3-devel-ubuntu24.04@sha256:392c0df7...

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(openjev): vast-train.sh retries the cargo build once; launch example sets --min-cuda 12.6

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(openjev): glibc preflight read via getconf (ldd|head tripped pipefail)

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(gpu-runner): default to CUDA 12.6 / Ubuntu 24.04 image

ort 2.0.0-rc.13's prebuilt onnxruntime needs glibc >= 2.38; the 22.04 image
(glibc 2.35) fails to link the OpenJev trainer. Digest verified by the
trainer's local image build.

Co-Authored-By: claude-flow <ruv@ruv.net>

* feat(typesafe): explicit calibration slice + public-suite validation view (OpenJev v1)

- core: Engine::train_with_calibration admits a held-out slice into the bank's
  Calibration split; when present, temperature/Platt fit on exactly that slice
  and the head on all Train rows. Without it the positional carve is unchanged
  (bit-identical; regression-checked on bge-small and OpenJev v0 receipts).
- ffi/wasm: trainJson accepts an optional "calibration" array.
- bench: tickets calibrate on the fixture calibration split by default
  (ADR-007 §4); --no-calibration-split restores the carve.
- bench: run.mjs --no-test on banking77/clinc150/hwu64 scores the exporter's
  validation slice (lib/public-val.mjs; row-set verified identical to the
  trainer's val.jsonl), never test.

Co-Authored-By: claude-flow <ruv@ruv.net>

* docs(openjev): v1 validation results (5 seeds) + shipped evaluation configuration

Co-Authored-By: claude-flow <ruv@ruv.net>

* docs(openjev): v1 public-suite validation (5 seeds vs base) + idle latency

Co-Authored-By: claude-flow <ruv@ruv.net>

* docs(openjev): v1 note — gate scope, data identity, import_bank side effect

Co-Authored-By: claude-flow <ruv@ruv.net>

* docs(openjev): v1 one-time frozen test results — secondary claim holds, primary + ECE gate not met

Seed 2 on the frozen 150-item test: department 93.3% (non-inferior to Jev),
urgent 92.7% and frustration 86.0% (both superior to Jev baseline and
champion), p95 10.1 ms, zero leakage. ECE 0.0543 fails the 0.05 gate.
Per ADR-007 §6 v1 is not published.

Co-Authored-By: claude-flow <ruv@ruv.net>

* docs(openjev): renumber OpenJev ADR to typesafe ADR-008; record v1 status

typesafe ADR-007 is taken on main by the ESP32 measured-sensor ADR (#1018),
so the OpenJev ADR becomes ADR-008 and references are updated. Frozen fixture
text (novel-slice comment, golden files, receipts) keeps its original
ADR-007 wording so the sha256 pins stay valid. Status now records the
one-time v1 test result: claim not met, model unpublished.

Co-Authored-By: claude-flow <ruv@ruv.net>

* docs(openjev): update remaining ADR-008 references in typesafe scripts

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-09-26 19:36:26 -05:00
..
benchmark chore: reorganize scripts into subfolders 2026-01-21 23:48:37 -05:00
build feat: Update NAPI-RS bindings with new capabilities (v0.1.15) 2025-11-26 18:47:48 +00:00
ci chore: reorganize scripts into subfolders 2026-01-21 23:48:37 -05:00
deploy chore: reorganize scripts into subfolders 2026-01-21 23:48:37 -05:00
lib fix(decompiler): statement-boundary splitting — 14/14 modules now parse (was 2/17) 2026-04-03 11:50:34 +00:00
openjev feat(openjev): OpenJev pipeline — Rust trainer, vast.ai runner, Jev-parity bench, calibration API (ADR-008); v1 results (#1029) 2026-09-26 19:36:26 -05:00
patches/hnsw_rs Add WebAssembly binary and TypeScript definitions for rvlite 2025-12-25 19:50:53 +00:00
publish fix: 9-issue cleanup batch + regression-guard CI workflow (#466) 2026-05-16 12:14:49 -04:00
research-gate fix(sota-bench): validate every Pareto axis, and drop to two objectives 2026-08-23 10:40:47 -04:00
sona-drift ci(sona): cross-implementation drift gate — parity harness, RVF fingerprints, stub tripwire (#554) 2026-06-11 22:40:27 -04:00
test chore: reorganize scripts into subfolders 2026-01-21 23:48:37 -05:00
training feat(training): source map extraction + v2 model (83.67% val accuracy) 2026-04-03 04:57:47 +00:00
validate chore: reorganize scripts into subfolders 2026-01-21 23:48:37 -05:00
adr-index.mjs fix(adr-index): harden traversal against symlinks, hostile filenames, adversarial trees (Phase-4 security review) 2026-08-20 08:39:24 -04:00
analyze-evolution.js feat: DrAgnes + Common Crawl WET + Gemini grounding agents (#282) 2026-03-23 10:12:50 -04:00
analyze-ham10000.js feat: DrAgnes + Common Crawl WET + Gemini grounding agents (#282) 2026-03-23 10:12:50 -04:00
build-solver.sh feat: Implement complete sublinear-time sparse solver crate 2026-02-20 06:49:14 +00:00
build-sonic-ct-wasm.sh feat(sonic_ct): acoustic digital human workbench — Rust/WASM USCT + R3F UI (#595) 2026-06-22 09:54:22 -04:00
check_brain_status.sh feat: add brain training and status scripts for pi.ruv.io 2026-03-16 23:14:43 -04:00
claude-code-decompile.sh feat(sse): decouple SSE to mcp.pi.ruv.io proxy + Claude Code source research 2026-04-02 23:39:56 +00:00
claude-code-rvf-corpus.sh feat(sse): decouple SSE to mcp.pi.ruv.io proxy + Claude Code source research 2026-04-02 23:39:56 +00:00
create-brainpedia.py fix: ruvector-postgres v0.3.1 — audit bug fixes, 46 SQL functions, Docker publish (#227) 2026-03-03 12:53:10 -05:00
deploy-crawl-phase1.sh feat: DrAgnes + Common Crawl WET + Gemini grounding agents (#282) 2026-03-23 10:12:50 -04:00
deploy-dragnes.sh feat(sse): decouple SSE to mcp.pi.ruv.io proxy + Claude Code source research 2026-04-02 23:39:56 +00:00
deploy-gemini-agents.sh feat: DrAgnes + Common Crawl WET + Gemini grounding agents (#282) 2026-03-23 10:12:50 -04:00
deploy-wet-job.sh feat: DrAgnes + Common Crawl WET + Gemini grounding agents (#282) 2026-03-23 10:12:50 -04:00
deploy_brain_services.sh fix(brain): pi.ruv.io 504 lock contention, UTF-8 crash, authenticated write paths (ADR-349) (#1023) 2026-09-26 13:24:58 -05:00
deploy_trainer.sh feat: update ADR-093 + add deploy_trainer.sh for Cloud Run scheduling 2026-03-16 23:14:43 -04:00
discover_and_train.sh feat: discover ↔ train feedback loop with live API discovery 2026-03-16 23:16:24 -04:00
extract-ruqu-rvdna-submodules.sh ADR-257: extract ruqu + rvdna into two standalone repos (git submodules) (#579) 2026-06-17 17:33:40 -04:00
frozen-weights-check.mjs fix(frozen-weights-check): sound bias-inverted comment handling closes the whole JS-regex FN class (PR #869 3rd re-verify) 2026-08-20 09:39:15 -04:00
gemini-agents.js feat: DrAgnes + Common Crawl WET + Gemini grounding agents (#282) 2026-03-23 10:12:50 -04:00
generate-rvf-manifest.py fix: ruvector-postgres v0.3.1 — audit bug fixes, 46 SQL functions, Docker publish (#227) 2026-03-03 12:53:10 -05:00
historical-crawl-import.sh feat: DrAgnes + Common Crawl WET + Gemini grounding agents (#282) 2026-03-23 10:12:50 -04:00
publish-rvf.sh feat(rvf): RuVector Format — Universal Cognitive Container SDK (#166) 2026-02-14 13:14:49 -05:00
README.md chore: reorganize scripts into subfolders 2026-01-21 23:48:37 -05:00
rebuild-all-versions.mjs feat(decompiler): rebuild all versions — organized source/rvf separation, 100% coverage 2026-04-03 03:18:41 +00:00
run_mincut_bench.sh feat: Add min-cut gating experiment scaffolding (WIP) 2026-02-20 06:52:43 +00:00
rvagent-flywheel-evaluator.mjs feat(rvagent): Hermes-class harness architecture — research, ADRs 273-279, harness repair + review fixes (#752) 2026-08-02 12:39:59 -03:00
rvforge-parity-check.sh feat(rvforge): create command, authoring core, and Reader install/library/update (#800) 2026-08-05 12:52:27 -03:00
rvforge-parity-fixture.cjs feat(rvforge): create command, authoring core, and Reader install/library/update (#800) 2026-08-05 12:52:27 -03:00
seed-brain-all.py fix: ruvector-postgres v0.3.1 — audit bug fixes, 46 SQL functions, Docker publish (#227) 2026-03-03 12:53:10 -05:00
seed-brain.rs fix: ruvector-postgres v0.3.1 — audit bug fixes, 46 SQL functions, Docker publish (#227) 2026-03-03 12:53:10 -05:00
seed-specialized.py fix: ruvector-postgres v0.3.1 — audit bug fixes, 46 SQL functions, Docker publish (#227) 2026-03-03 12:53:10 -05:00
setup-gcs-examples.sh fix: ruvector-postgres v0.3.1 — audit bug fixes, 46 SQL functions, Docker publish (#227) 2026-03-03 12:53:10 -05:00
sift1m_hnswlib_bench.mjs perf(hnsw): 4-acc AVX-512 + parallel-insert — +9.7% build throughput (query QPS unchanged: memory-bound at 1M scale) (#619) 2026-06-28 20:45:35 -04:00
sql-audit-v3.sql fix: ruvector-postgres v0.3.2 — 100% audit pass (HNSW + hybrid fixes) (#230) 2026-03-03 13:21:48 -05:00
swarm_train_15.sh feat: 15-agent concurrent discovery swarm with 12 new data sources 2026-03-16 23:16:24 -04:00
sync-lockfile.sh style: apply rustfmt across entire codebase 2026-01-28 17:00:26 +00:00
train-lora.py fix: ruvector-postgres v0.3.1 — audit bug fixes, 46 SQL functions, Docker publish (#227) 2026-03-03 12:53:10 -05:00
train_brain.sh feat: brain trainer core module + auth fix — 56 discoveries ingested 2026-03-16 23:14:43 -04:00
training_orchestrator.sh update: training orchestrator with improved PII stripping and color output 2026-03-16 23:21:01 -04:00
upvote_memories.py fix(brain): defer sparsifier build on startup for large graphs 2026-03-24 12:29:52 +00:00
vote-boost.py fix: ruvector-postgres v0.3.1 — audit bug fixes, 46 SQL functions, Docker publish (#227) 2026-03-03 12:53:10 -05:00
wet-filter-inject.js feat: DrAgnes + Common Crawl WET + Gemini grounding agents (#282) 2026-03-23 10:12:50 -04:00
wet-full-import.sh feat: DrAgnes + Common Crawl WET + Gemini grounding agents (#282) 2026-03-23 10:12:50 -04:00
wet-job.yaml feat: DrAgnes + Common Crawl WET + Gemini grounding agents (#282) 2026-03-23 10:12:50 -04:00
wet-orchestrate.sh feat: DrAgnes + Common Crawl WET + Gemini grounding agents (#282) 2026-03-23 10:12:50 -04:00
wet-processor.sh feat: DrAgnes + Common Crawl WET + Gemini grounding agents (#282) 2026-03-23 10:12:50 -04:00
workspace-check.mjs fix(workspace): add orphan crates to workspace, add membership guard (PIR #859) 2026-08-20 08:22:28 -04:00

RuVector Automation Scripts

This directory contains automation scripts organized by purpose.

📁 Directory Structure

scripts/
├── README.md           # This file
├── benchmark/          # Performance benchmarking
├── build/              # Build utilities
├── ci/                 # CI/CD automation
├── deploy/             # Deployment scripts
├── patches/            # Patch files
├── publish/            # Package publishing
├── test/               # Testing scripts
└── validate/           # Validation & verification

🚀 Deployment

Scripts for deploying to production.

Script Description
deploy/deploy.sh Comprehensive deployment (crates.io + npm)
deploy/test-deploy.sh Test deployment without publishing
deploy/DEPLOYMENT.md Full deployment documentation
deploy/DEPLOYMENT-QUICKSTART.md Quick deployment guide

Usage:

# Full deployment
./scripts/deploy/deploy.sh

# Dry run
./scripts/deploy/deploy.sh --dry-run

# Test deployment
./scripts/deploy/test-deploy.sh

📦 Publishing

Scripts for publishing packages to registries.

Script Description
publish/publish-all.sh Publish all packages
publish/publish-crates.sh Publish Rust crates to crates.io
publish/publish-cli.sh Publish CLI package
publish/publish-router-wasm.sh Publish router WASM package
publish/check-and-publish-router-wasm.sh Check and publish router WASM

Usage:

# Set credentials first
export CRATES_API_KEY="your-crates-io-token"
export NPM_TOKEN="your-npm-token"

# Publish all
./scripts/publish/publish-all.sh

# Publish crates only
./scripts/publish/publish-crates.sh

📊 Benchmarking

Performance benchmarking scripts.

Script Description
benchmark/run_benchmarks.sh Run core benchmarks
benchmark/run_llm_benchmarks.sh Run LLM inference benchmarks

Usage:

# Run core benchmarks
./scripts/benchmark/run_benchmarks.sh

# Run LLM benchmarks
./scripts/benchmark/run_llm_benchmarks.sh

🧪 Testing

Testing and validation scripts.

Script Description
test/test-wasm.mjs Test WASM bindings
test/test-graph-cli.sh Test graph CLI commands
test/test-all-graph-commands.sh Test all graph commands
test/test-docker-package.sh Test Docker packaging

Usage:

# Test WASM
node ./scripts/test/test-wasm.mjs

# Test graph CLI
./scripts/test/test-graph-cli.sh

✅ Validation

Package and build verification scripts.

Script Description
validate/validate-packages.sh Validate package configs
validate/validate-packages-simple.sh Simple package validation
validate/verify-paper-impl.sh Verify paper implementation
validate/verify_hnsw_build.sh Verify HNSW build

Usage:

# Validate packages
./scripts/validate/validate-packages.sh

# Verify HNSW
./scripts/validate/verify_hnsw_build.sh

🔄 CI/CD

Continuous integration scripts.

Script Description
ci/ci-sync-lockfile.sh Auto-fix lock files in CI
ci/sync-lockfile.sh Sync package-lock.json
ci/install-hooks.sh Install git hooks

Usage:

# Install git hooks (recommended)
./scripts/ci/install-hooks.sh

# Sync lockfile
./scripts/ci/sync-lockfile.sh

🛠️ Build

Build utility scripts located in build/.

🩹 Patches

Patch files for dependencies located in patches/.

🚀 Quick Start

For Development

  1. Install git hooks (recommended):

    ./scripts/ci/install-hooks.sh
    
  2. Run tests:

    ./scripts/test/test-wasm.mjs
    

For Deployment

  1. Set credentials:

    export CRATES_API_KEY="your-crates-io-token"
    export NPM_TOKEN="your-npm-token"
    
  2. Dry run first:

    ./scripts/deploy/deploy.sh --dry-run
    
  3. Deploy:

    ./scripts/deploy/deploy.sh
    

🔐 Security

Never commit credentials! Always use environment variables or .env file.

See deploy/DEPLOYMENT.md for security best practices.