mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-23 04:27:11 +00:00
Implements the full delta-behavior framework - systems where change is permitted but collapse is not. ## Core Implementation - Coherence type with [0,1] bounds and safe constructors - Three-layer enforcement: energy cost, scheduling, memory gating - DeltaSystem trait for coherence-preserving systems - DeltaConfig with strict/relaxed/default presets ## 11 Exotic Applications 1. Self-Limiting Reasoning - AI that does less when uncertain 2. Computational Event Horizon - bounded computation without hard limits 3. Artificial Homeostasis - synthetic life with coherence-based survival 4. Self-Stabilizing World Model - models that refuse to hallucinate 5. Coherence-Bounded Creativity - novelty without chaos 6. Anti-Cascade Financial System - markets that cannot collapse 7. Graceful Aging - systems that simplify over time 8. Swarm Intelligence - collective behavior without pathology 9. Graceful Shutdown - systems that seek safe termination 10. Pre-AGI Containment - bounded intelligence growth 11. Extropic Substrate - goal mutation, agent lifecycles, spike semantics ## Performance Optimizations - O(n²) → O(n·k) swarm neighbor detection via SpatialGrid - O(n) → O(1) coherence calculation with incremental cache - VecDeque for O(1) history removal - SIMD utilities with 8x loop unrolling - Bounded history to prevent memory leaks ## Security Fixes - Replaced unsafe static mut with AtomicU64 for thread-safe RNG - NaN validation on all coherence inputs - Overflow protection in calculations ## WASM + TypeScript SDK - Full wasm-bindgen exports for all 11 applications - High-level TypeScript SDK with ergonomic APIs - Browser and Node.js examples ## Test Coverage - 32 lib tests, 14 WASM tests, 13 doc tests (59 total) Resolves #140 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
122 lines
3.3 KiB
Bash
Executable file
122 lines
3.3 KiB
Bash
Executable file
#!/bin/bash
|
|
# Build script for Delta-Behavior WASM bindings
|
|
# This script builds the Rust code to WebAssembly using wasm-pack
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
echo "=== Delta-Behavior WASM Build ==="
|
|
echo "Project directory: $PROJECT_DIR"
|
|
echo ""
|
|
|
|
# Check for wasm-pack
|
|
if ! command -v wasm-pack &> /dev/null; then
|
|
echo "wasm-pack not found. Installing..."
|
|
cargo install wasm-pack
|
|
fi
|
|
|
|
# Check for wasm32 target
|
|
if ! rustup target list --installed | grep -q wasm32-unknown-unknown; then
|
|
echo "Adding wasm32-unknown-unknown target..."
|
|
rustup target add wasm32-unknown-unknown
|
|
fi
|
|
|
|
cd "$PROJECT_DIR"
|
|
|
|
# Parse arguments
|
|
TARGET="web"
|
|
PROFILE="release"
|
|
OUT_DIR="wasm/pkg"
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
--target)
|
|
TARGET="$2"
|
|
shift 2
|
|
;;
|
|
--dev)
|
|
PROFILE="dev"
|
|
shift
|
|
;;
|
|
--release)
|
|
PROFILE="release"
|
|
shift
|
|
;;
|
|
--out-dir)
|
|
OUT_DIR="$2"
|
|
shift 2
|
|
;;
|
|
--help|-h)
|
|
echo "Usage: $0 [OPTIONS]"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " --target <TARGET> Build target: web, nodejs, bundler (default: web)"
|
|
echo " --dev Build in development mode"
|
|
echo " --release Build in release mode (default)"
|
|
echo " --out-dir <DIR> Output directory (default: wasm/pkg)"
|
|
echo " --help, -h Show this help message"
|
|
echo ""
|
|
echo "Examples:"
|
|
echo " $0 # Build for web in release mode"
|
|
echo " $0 --target nodejs # Build for Node.js"
|
|
echo " $0 --dev # Build in development mode"
|
|
echo " $0 --target bundler # Build for bundlers (webpack, etc.)"
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Unknown option: $1"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
echo "Building with:"
|
|
echo " Target: $TARGET"
|
|
echo " Profile: $PROFILE"
|
|
echo " Output: $OUT_DIR"
|
|
echo ""
|
|
|
|
# Build options
|
|
BUILD_OPTS="--target $TARGET --out-dir $OUT_DIR"
|
|
|
|
if [ "$PROFILE" = "dev" ]; then
|
|
BUILD_OPTS="$BUILD_OPTS --dev"
|
|
else
|
|
BUILD_OPTS="$BUILD_OPTS --release"
|
|
fi
|
|
|
|
# Run wasm-pack build
|
|
echo "Running: wasm-pack build $BUILD_OPTS"
|
|
wasm-pack build $BUILD_OPTS
|
|
|
|
# Post-build: Copy TypeScript declarations
|
|
if [ -f "wasm/index.d.ts" ]; then
|
|
echo ""
|
|
echo "Copying TypeScript declarations..."
|
|
cp wasm/index.d.ts "$OUT_DIR/"
|
|
fi
|
|
|
|
# Calculate sizes
|
|
if [ -f "$OUT_DIR/delta_behavior_bg.wasm" ]; then
|
|
WASM_SIZE=$(wc -c < "$OUT_DIR/delta_behavior_bg.wasm")
|
|
WASM_SIZE_KB=$((WASM_SIZE / 1024))
|
|
echo ""
|
|
echo "=== Build Complete ==="
|
|
echo "WASM size: ${WASM_SIZE_KB}KB ($WASM_SIZE bytes)"
|
|
fi
|
|
|
|
# List output files
|
|
echo ""
|
|
echo "Output files in $OUT_DIR:"
|
|
ls -la "$OUT_DIR/"
|
|
|
|
echo ""
|
|
echo "To use in a web project:"
|
|
echo " import init, { WasmCoherence, WasmEventHorizon } from './$OUT_DIR/delta_behavior.js';"
|
|
echo " await init();"
|
|
echo ""
|
|
echo "To use in Node.js (if built with --target nodejs):"
|
|
echo " const { WasmCoherence, WasmEventHorizon } = require('./$OUT_DIR/delta_behavior.js');"
|
|
echo ""
|