Skip to content

research(ruvector-field): field subsystem spec and runnable example#345

Open
ruvnet wants to merge 2534 commits intomainfrom
claude/ruvector-field-spec-lJEtH
Open

research(ruvector-field): field subsystem spec and runnable example#345
ruvnet wants to merge 2534 commits intomainfrom
claude/ruvector-field-spec-lJEtH

Conversation

@ruvnet
Copy link
Copy Markdown
Owner

@ruvnet ruvnet commented Apr 12, 2026

Add optional RuVector field layer above the kernel and coherence engine.
Shells (Event/Pattern/Concept/Principle), geometric vs semantic antipodes,
multiplicative resonance, four-channel drift, routing hints as advisory
state. Aligned with the RuVix EPIC acceptance criteria — does not alter
v1 boot, witness, proof, or the 50 us coherence epoch budget.

  • docs/research/ruvector-field/SPEC.md: full specification
  • examples/ruvector-field: standalone std-only Rust demo (field_demo)

ruvnet and others added 30 commits March 20, 2026 10:37
* feat: add ruvector-sparsifier crate — dynamic spectral graph sparsification

Implements AdaptiveGeoSpar, a dynamic spectral sparsifier that maintains
a compressed shadow graph preserving Laplacian energy within (1±ε).

Core crate (ruvector-sparsifier):
- SparseGraph with dynamic edge operations and Laplacian QF
- Backbone spanning forest via union-find for connectivity
- Random walk effective resistance estimation for importance scoring
- Spectral sampling proportional to weight × importance × log(n)/ε²
- SpectralAuditor with quadratic form, cut, and conductance probes
- Pluggable traits: Sparsifier, ImportanceScorer, BackboneStrategy
- 49 tests (31 unit + 17 integration + 1 doc-test), all passing
- Benchmarks: build 161µs, insert 81µs, audit 39µs (n=100)

WASM crate (ruvector-sparsifier-wasm):
- Full wasm-bindgen bindings via WasmSparsifier and WasmSparseGraph
- JSON-based API for browser/edge deployment
- Compiles cleanly on native target

Research (docs/research/spectral-sparsification/):
- 00: Executive summary and impact projections
- 01: SOTA survey (ADKKP 2016 → STACS 2026)
- 02: Rust crate design and API
- 03: RuVector integration architecture (4-tier control plane)
- 04: Companion systems (conformal drift, attributed ANN)

https://claude.ai/code/session_01A6YKtTrSPeV36Xamz9hRCb

* perf: ultra optimizations across core distance, SIMD, and sparsifier hot paths

Core distance.rs:
- Manhattan distance now delegates to SIMD (was pure scalar)
- Cosine fallback uses single-pass computation (was 3 separate passes)
- Euclidean fallback uses 4x loop unrolling for better ILP

SIMD intrinsics:
- Add AVX2 manhattan distance (was only AVX-512 or scalar fallback)
- 2x loop unrolling with dual accumulators for AVX2 manhattan
- Sign-bit mask absolute value for branchless abs diff

Sparsifier (O(m) -> O(1) per insert):
- Cache total importance to avoid iterating ALL edges per insert
- Parallel edge scoring via rayon for graphs >100 edges
- Pre-sized HashMap adjacency lists (4 neighbors avg)
- Inline annotations on hot-path graph query methods

https://claude.ai/code/session_01A6YKtTrSPeV36Xamz9hRCb

* fix: resolve clippy warnings in ruvector-sparsifier

- Replace map_or(false, ...) with is_some_and(...) in graph.rs
- Derive Default instead of manual impl for LocalImportanceScorer
- Fix inner/outer attribute conflict on prelude module

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit 1d60bf0

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
  Built from commit 3b0cfaa

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit 4737167

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
Describes how ruvector-sparsifier integrates into the brain server's
KnowledgeGraph for O(n log n) analytics instead of O(n²).

Co-Authored-By: claude-flow <ruv@ruv.net>
Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit 881e57e

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
  Built from commit 9679411

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
…116)

* feat: integrate ruvector-sparsifier into brain server (ADR-116)

- Add ruvector-sparsifier dependency to mcp-brain-server
- KnowledgeGraph now maintains an AdaptiveGeoSpar alongside full graph
- Sparsifier updates incrementally on add_memory / remove_memory
- Lazy initialization: sparsifier builds on first access or startup hydration
- rebuild_graph optimization action also rebuilds the sparsifier
- StatusResponse exposes sparsifier_compression and sparsifier_edges
- Full graph preserved for exact lookups — sparsifier is additive only

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

* build: add ruvector-sparsifier to Docker build context

- Add COPY for ruvector-sparsifier crate
- Add to workspace members in Cargo.workspace.toml
- Strip bench/example sections from sparsifier Cargo.toml in Docker

Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit 61164d9

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
The Dockerfile comments out the simd_intrinsics module but distance.rs
still referenced it. Replace with pure Rust fallback for Cloud Run build.

Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit 3e554c9

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
* docs: DrAgnes project overview and system architecture research

Establishes the DrAgnes AI-powered dermatology intelligence platform
research initiative with comprehensive system architecture covering
DermLite integration, CNN classification pipeline, brain collective
learning, offline-first PWA design, and 25-year evolution roadmap.

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

* docs: DrAgnes HIPAA compliance strategy and data sources research

Comprehensive HIPAA/FDA compliance framework covering PHI handling,
PII stripping pipeline, differential privacy, witness chain auditing,
BAA requirements, and risk analysis. Data sources document catalogs
18 training datasets, medical literature sources, and real-world data
streams including HAM10000, ISIC Archive, and Fitzpatrick17k.

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

* docs: DrAgnes DermLite integration and 25-year future vision research

DermLite integration covers HUD/DL5/DL4/DL200 device capabilities,
image capture via MediaStream API, ABCDE criteria automation, 7-point
checklist, Menzies method, and pattern analysis modules. Future vision
spans AR-guided biopsy (2028), continuous monitoring wearables (2040),
genomic fusion (2035), BCI clinical gestalt (2045), and global
elimination of late-stage melanoma detection by 2050.

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

* docs: DrAgnes competitive analysis and deployment plan research

Competitive analysis covers SkinVision, MoleMap, MetaOptima, Canfield,
Google Health, 3Derm, and MelaFind with feature matrix comparison.
Deployment plan details Google Cloud architecture with Cloud Run
services, Firestore/GCS data storage, Pub/Sub events, multi-region
strategy, security configuration, cost projections ($3.89/practice at
1000-practice scale), and disaster recovery procedures.

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

* docs: ADR-117 DrAgnes dermatology intelligence platform

Proposes DrAgnes as an AI-powered dermatology platform built on
RuVector's CNN, brain, and WASM infrastructure. Covers architecture,
data model, API design, HIPAA/FDA compliance strategy, 4-phase
implementation plan (2026-2051), cost model showing $3.89/practice
at scale, and acceptance criteria targeting >95% melanoma sensitivity
with offline-first WASM inference in <200ms.

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

* feat(dragnes): deployment config — Dockerfile, Cloud Run, PWA manifest, service worker

Add production deployment infrastructure for DrAgnes:
- Multi-stage Dockerfile with Node 20 Alpine and non-root user
- Cloud Run knative service YAML (1-10 instances, 2 vCPU, 2 GiB)
- GCP deploy script with rollback support and secrets integration
- PWA manifest with SVG icons (192x192, 512x512)
- Service worker with offline WASM caching and background sync
- TypeScript configuration module with CNN, privacy, and brain settings

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

* docs(dragnes): user-facing documentation and clinical guide

Add comprehensive DrAgnes documentation covering:
- Getting started and PWA installation
- DermLite device integration instructions
- HAM10000 classification taxonomy and result interpretation
- ABCDE dermoscopy scoring methodology
- Privacy architecture (DP, k-anonymity, witness hashing)
- Offline mode and background sync behavior
- Troubleshooting guide
- Clinical disclaimer and regulatory status

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

* feat(dragnes): brain integration — pi.ruv.io client, offline queue, witness chains, API routes

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

* feat(dragnes): CNN classification pipeline with ABCDE scoring and privacy layer

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

* fix(dragnes): resolve build errors by externalizing @ruvector/cnn

Mark @ruvector/cnn as external in Rollup/SSR config so the dynamic
import in the classifier does not break the production build.

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

* feat(dragnes): app integration, health endpoint, build validation

- Add DrAgnes nav link to sidebar NavMenu
- Create /api/dragnes/health endpoint with config status
- Add config module exporting DRAGNES_CONFIG
- Update DrAgnes page with loading state & error boundaries
- All 37 tests pass, production build succeeds

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

* feat(dragnes): benchmarks, dataset metadata, federated learning, deployment runbook

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

* fix(dragnes): use @vite-ignore for optional @ruvector/cnn import

Prevents Vite dev server from failing on the optional WASM dependency
by using /* @vite-ignore */ comment and variable-based import path.

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

* fix(dragnes): reduce false positives with Bayesian-calibrated classifier

Apply HAM10000 class priors as Bayesian log-priors to demo classifier,
learned from pi.ruv.io brain specialist agent patterns:
- nv (66.95%) gets strong prior, reducing over-classification of rare types
- mel requires multiple simultaneous features (dark + blue + multicolor +
  high variance) to overcome its 11.11% prior
- Added color variance analysis as asymmetry proxy
- Added dermoscopic color count for multi-color detection
- Platt-calibrated feature weights from brain melanoma specialist

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

* fix(dragnes): require ≥2 concurrent evidence signals for melanoma

A uniformly dark spot was triggering melanoma at 74.5%. Now requires
at least 2 of: [dark >15%, blue-gray >3%, ≥3 colors, high variance]
to overcome the melanoma prior. Proven on 6 synthetic test cases:
0 false positives, 1/1 true melanoma detected at 91.3%.

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

* data(dragnes): HAM10000 metadata and analysis script

Add comprehensive analysis of the HAM10000 skin lesion dataset based on
published statistics from Tschandl et al. 2018. Generates class distribution,
demographic, localization, diagnostic method, and clinical risk pattern
analysis. Outputs both markdown report and JSON stats for the knowledge module.

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

* feat(dragnes): HAM10000 clinical knowledge module with demographic adjustment

Add ham10000-knowledge.ts encoding verified HAM10000 statistics as structured
data for Bayesian demographic adjustment. Includes per-class age/sex/location
risk multipliers, clinical decision thresholds (biopsy at P(mal)>30%, urgent
referral at P(mel)>50%), and adjustForDemographics() function implementing
posterior probability correction based on patient demographics.

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

* feat(dragnes): integrate HAM10000 knowledge into classifier

Add classifyWithDemographics() method to DermClassifier that applies Bayesian
demographic adjustment after CNN classification. Returns both raw and adjusted
probabilities for transparency, plus clinical recommendations (biopsy, urgent
referral, monitor, or reassurance) based on HAM10000 evidence thresholds.

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

* feat(dragnes): wire HAM10000 demographics into UI

- Add patient age/sex inputs in Capture tab
- Toggle for HAM10000 Bayesian adjustment
- Pass body location from DermCapture to classifyWithDemographics()
- Clinical recommendation banner in Results tab with color-coded
  risk levels (urgent_referral/biopsy/monitor/reassurance)
- Shows melanoma + malignant probabilities and reasoning

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

* refactor(dragnes): move to standalone examples/dragnes/ app

Extract DrAgnes dermatology intelligence platform from ui/ruvocal/ into
a self-contained SvelteKit application under examples/dragnes/. Includes
all library modules, components, API routes, tests, deployment config,
PWA assets, and research documentation. Updated paths for standalone
routing (no /dragnes prefix), fixed static asset references, and
adjusted test imports.

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

* revert: restore ui/ruvocal to main state -- remove DrAgnes commingling

Remove all DrAgnes-related files, components, routes, and config from
ui/ruvocal/ so it matches the main branch exactly. DrAgnes now lives
as a standalone app in examples/dragnes/.

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

* fix(ruvocal): fix icon 404 and FoundationBackground crash

- Manifest icon paths: /chat/chatui/ → /chatui/ (matches static dir)
- FoundationBackground: guard against undefined particles in connections

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

* fix(ruvocal): MCP SSE auto-reconnect on stale session (404/connection errors)

- Widen isConnectionClosedError to catch 404, fetch failed, ECONNRESET
- Add transport readyState check in clientPool for dead connections
- Retry logic now triggers reconnection on stale SSE sessions

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

* chore: update gitignore for nested .env files and Cargo.lock

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

* docs: update links in README for self-learning, self-optimizing, embeddings, verified training, search, storage, PostgreSQL, graph, AI runtime, ML framework, coherence, domain models, hardware, kernel, coordination, packaging, routing, observability, safety, crypto, and lineage sections

* docs: ADR-115 cost-effective strategy + ADR-118 tiered crawl budget

Add Section 15 to ADR-115 with cost-effective implementation strategy:
- Three-phase budget model ($11-28/mo -> $73-108 -> $158-308)
- CostGuardrails Rust struct with per-phase presets
- Sparsifier-aware graph management (partition on sparse edges)
- Partition timeout fix via caching + background recompute
- Cloud Scheduler YAML for crawl jobs
- Anti-patterns and cost monitoring

Create ADR-118 as standalone cost strategy ADR with:
- Detailed per-phase cost breakdowns
- Guardrail enforcement points
- Partition caching strategy with request flow
- Acceptance criteria tied to cost targets

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

* docs: add pi.ruv.io brain guidance and project structure to CLAUDE.md

- When/how to use brain MCP tools during development
- Brain REST API fallback when MCP SSE is stale
- Google Cloud secrets and deployment reference
- Project directory structure quick reference
- Key rules: no PHI/secrets in brain, category taxonomy, stale session fix

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

* docs: Common Crawl Phase 1 benchmark — pipeline validation results

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

* fix(brain): make InjectRequest.source optional for batch inject

The batch endpoint falls back to BatchInjectRequest.source when items
don't have their own source field, but serde deserialization failed
before the handler could apply this logic (422). Adding #[serde(default)]
lets items omit source when using batch inject.

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

* feat: Common Crawl Phase 1 deployment script — medical domain scheduler jobs

Deploy CDX-targeted crawl for PubMed + dermatology domains via Cloud Scheduler.
Uses static Bearer auth (brain server API key) instead of OIDC since Cloud Run
allows unauthenticated access and brain's auth rejects long JWT tokens.

Jobs: brain-crawl-medical (daily 2AM, 100 pages), brain-crawl-derm (daily 3AM,
50 pages), brain-partition-cache (hourly graph rebuild).

Tested: 10 new memories injected from first run (1568->1578). CDX falls back to
Wayback API from Cloud Run. ADR-118 Phase 1 implementation.

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

* feat: ADR-119 historical crawl evolutionary comparison

Implement temporal knowledge evolution tracking across quarterly
Common Crawl snapshots (2020-2026). Includes:
- ADR-119 with architecture, cost model, acceptance criteria
- Historical crawl import script (14 quarterly snapshots, 5 domains)
- Evolutionary analysis module (drift detection, concept birth, similarity)
- Initial analysis report on existing brain content (71 memories)

Cost: ~$7-15 one-time for full 2020-2026 import.

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

* docs: update ADR-115/118/119 with Phase 1 implementation results

- ADR-115: Status → Phase 1 Implemented, actual import numbers (1,588 memories,
  372K edges, 28.7x sparsifier), CDX vs direct inject pipeline status
- ADR-118: Status → Phase 1 Active, scheduler jobs documented, CDX HTML
  extractor issue + direct inject workaround, actual vs projected cost
- ADR-119: 30+ temporal articles imported (2020-2026), search verification
  confirmed, acceptance criteria progress tracked

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

* feat: WET processing pipeline for full medical + CS corpus import (ADR-120)

Bypasses broken CDX HTML extractor by processing pre-extracted text
from Common Crawl WET files. Filters by 30 medical + CS domains,
chunks content, and batch injects into pi.ruv.io brain.

Includes: processor, filter/injector, Cloud Run Job config,
orchestrator for multi-segment processing.

Target: full corpus in 6 weeks at ~$200 total cost.

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

* feat: Cloud Run Job deployment for full 6-year Common Crawl import

- Expanded domain list to 60+ medical + CS domains with categorized tagging
- Cloud Run Job config: 10 parallel tasks, 100 segments per crawl
- Multi-crawl orchestrator for 14 quarterly snapshots (2020-2026)
- Enhanced generateTags with domain-specific labels for oncology, dermatology,
  ML conferences, research labs, and academic institutions
- Target: 375K-500K medical/CS pages over 5 months

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

* fix: correct Cloud Run Job deploy to use env-vars-file and --source build

- Use --env-vars-file (YAML) to avoid comma-splitting in domain list
- Use --source deploy to auto-build container from Dockerfile
- Use correct GCS bucket (ruvector-brain-us-central1)
- Use --tasks flag instead of --task-count

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

* fix: bake WET paths into container image to avoid GCS auth at runtime

- Embed paths.txt directly into Docker image during build
- Remove GCS bucket dependency from entrypoint
- Add diagnostic logging for brain URL and crawl index per task

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

* docs: update ADR-120 with deployment results and expanded domain list

- Status → Phase 1 Deployed
- 8 local segments: 109 pages injected from 170K scanned
- Cloud Run Job executing (50 segments, 10 parallel)
- 4 issues fixed (paths corruption, task index, comma splitting, gsutil)
- Domain list expanded 30 → 60+
- Brain: 1,768 memories, 565K edges, 39.8x sparsifier

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

* fix: WET processor OOM — process records inline, increase memory to 2Gi

Node.js heap exhausted at 512MB buffering 21K WARC records.
Fix: process each record immediately instead of accumulating in
pendingRecords array. Also cap per-record content length and
increase Cloud Run Job memory from 1Gi to 2Gi with --max-old-space-size=1536.

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

* feat: add 30 physics domains + keyword detection to WET crawler

Add CERN, INSPIRE-HEP, ADS, NASA, LIGO, Fermilab, SLAC, NIST,
Materials Project, Quanta Magazine, quantum journals, IOP, APS,
and national labs. Physics keyword detection for dark matter,
quantum, Higgs, gravitational waves, black holes, condensed matter,
fusion energy, neutrinos, and string theory.

Total domains: 90+ (medical + CS + physics).

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

* feat: expand WET crawler to 130+ domains across all knowledge areas

Added: GitHub, Stack Overflow/Exchange, patent databases (USPTO, EPO),
preprint servers (bioRxiv, medRxiv, chemRxiv, SSRN), Wikipedia,
government (NSF, DARPA, DOE, EPA), science news, academic publishers
(JSTOR, Cambridge, Sage, Taylor & Francis), data repositories
(Kaggle, Zenodo, Figshare), and ML explainer blogs.

Total: 130+ domains covering medical, CS, physics, code, patents,
preprints, regulatory, news, and open data.

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

* fix(brain): update Gemini model to gemini-2.5-flash with env override

Old model ID gemini-2.5-flash-preview-05-20 was returning 404.
Updated default to gemini-2.5-flash (stable release).
Added GEMINI_MODEL env var override for future flexibility.

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

* feat(brain): integrate Google Search Grounding into Gemini optimizer (ADR-121)

Add google_search tool to Gemini API calls so the optimizer verifies
generated propositions against live web sources. Grounding metadata
(source URLs, support scores, search queries) logged for auditability.

- google_search tool added to request body
- Grounding metadata parsed and logged
- Configurable via GEMINI_GROUNDING env var (default: true)
- Model updated to gemini-2.5-flash (stable)
- ADR-121 documents integration

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

* fix(brain): deploy-all.sh preserves env vars, includes all features

CRITICAL FIX: Changed --set-env-vars to --update-env-vars so deploys
don't wipe FIRESTORE_URL, GEMINI_API_KEY, and feature flags.

Now includes:
- FIRESTORE_URL auto-constructed from PROJECT_ID
- GEMINI_API_KEY fetched from Google Secrets Manager
- All 22 feature flags (GWT, SONA, Hopfield, HDC, DentateGyrus,
  midstream, sparsifier, DP, grounding, etc.)
- Session affinity for SSE MCP connections

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

* docs: update ADR-121 with deployment verification and optimization gaps

- Verified: Gemini 2.5 Flash + grounding working
- Brain: 1,808 memories, 611K edges, 42.4x sparsifier
- Documented 5 optimization opportunities:
  1. Graph rebuild timeout (>90s for 611K edges)
  2. In-memory state loss on deploy
  3. SONA needs trajectory injection path
  4. Scheduler jobs need first auto-fire
  5. WET daily needs segment rotation

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

* docs: design rvagent autonomous Gemini grounding agents (ADR-122)

Four-phase system for autonomous knowledge verification and enrichment
of the pi.ruv.io brain using Gemini 2.5 Flash with Google Search
grounding. Addresses the gap where all 11 propositions are is_type_of
and the Horn clause engine has no relational data to chain.

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

* docs: ADR-122 Rev 2 — candidate graph, truth maintenance, provenance

Applied 6 priority revisions from architecture review:
1. Reworked cost model with 3 scenarios (base/expected/worst)
2. Added candidate vs canonical graph separation with promotion gates
3. Narrowed predicate set to causes/treats/depends_on/part_of/measured_by
4. Replaced regex-only PHI with allowlist-based serialization
5. Added truth maintenance state machine (7 proposition states)
6. Added provenance schema for every grounded mutation

Status: Approved with Revisions

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

* feat: implement 4 Gemini grounding agents + Cloud Run deploy (ADR-122)

Phase 1 (Fact Verifier): verified 2 memories with grounding sources
Phase 2 (Relation Generator): found 1 'contradicts' relation
Phase 3 (Cross-Domain Explorer): framework working, needs JSON parse fix
Phase 4 (Research Director): framework working, needs drift data

Scripts: gemini-agents.js, deploy-gemini-agents.sh
Cloud Run Job + 4 scheduler entries deploying.
Brain grew: 1,809 → 1,812 (+3 from initial run)

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

* perf(brain): upgrade to 4 CPU / 4 GiB / 20 instances + rate limit WET injector

- Cloud Run: 2 CPU → 4 CPU, 2 GiB → 4 GiB, max 10 → 20 instances
- WET injector: 1s delay between batch injects to prevent brain saturation
- Deploy script updated to match new resource allocation

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

* docs: ADR-122 Rev 2 — candidate graph, truth maintenance, provenance

Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit 326fc77

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
#273: trajectoriesRecorded always returns 0
Root cause: Rust CoordinatorStats serializes as trajectories_buffered
but TypeScript expects trajectoriesRecorded. Added trajectories_recorded
field and mapped snake_case → camelCase in TypeScript wrapper.

#274: Save/load learned state for persistence across restarts
Added serialize_state() to LoopCoordinator and saveState() to
NAPI + TypeScript wrapper.
Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit 32332e6

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
  Built from commit 1b1a85a

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
  Built from commit 4aa0bf7

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
#274)

Completes #274 by adding the load path for SONA state persistence:

- ReasoningBank.insert_pattern(): directly insert a pattern (for restore)
- LoopCoordinator.load_state(json): deserialize and restore patterns
- NAPI loadState(stateJson): binding for Node.js
- TypeScript loadState(stateJson): wrapper with return count

Full save/load cycle now works:
  const state = engine.saveState();    // serialize patterns to JSON
  // ... restart ...
  const restored = engine.loadState(state);  // restore N patterns

serialize_state() now includes full pattern data (centroids, quality,
cluster sizes) not just counts.
Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit c023e94

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
  Built from commit a27b38f

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
Added two hooks to .claude/settings.json:

1. SessionEnd: shares session summary (branch, last 5 commits, diff stat)
   to pi.ruv.io brain. Runs async, won't block session exit.

2. PostToolUse/Bash: after git commit commands, shares the commit message
   to brain. Only triggers on "git commit", skips all other bash commands.

Both hooks use BRAIN_API_KEY env var (fallback to hardcoded key).
Added BRAIN_API_KEY and BRAIN_URL to env section.

Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit c39dccb

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
…nitive enrichment

The MCP SDK's EventSource polyfill briefly drops the SSE connection during
initialization, causing the session to be removed before the client can POST.
Added a 30-second grace period so sessions survive brief reconnects.

Also includes ADR-123: drift snapshots from cluster centroids and auto-populate
GWT working memory from search results.

Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit a697632

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
github-actions Bot and others added 29 commits April 7, 2026 01:24
  Built from commit c53938a

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
  Built from commit 4bcceb5

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
ADR-145: Fix training pipeline issues across WASM and NAPI bindings.

WASM (ruvector-attention-wasm):
- Replace serde_wasm_bindgen deserialization of negatives param with
  explicit js_sys::Float32Array conversion. TypedArrays don't
  deserialize via serde — use js_sys::Array iteration instead.

NAPI (ruvector-attention-node):
- Add stepInPlace() to SGD, Adam, AdamW optimizers for zero-copy
  in-place parameter mutation via Float32Array's AsMut<[f32]>
- Document that step() returns a NEW array (callers must use return)

Note: LoRA B=0 initialization in learning-wasm is correct by design
(Hu et al. 2021) — documented in ADR-145, no code change needed.

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
  Built from commit 3e67c72

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc
  - wasm

  🤖 Generated by GitHub Actions
  Built from commit 3e67c72

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
  Built from commit 3e67c72

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
  Built from commit 86f671a

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc
  - wasm

  🤖 Generated by GitHub Actions
- diskann-wrapper.ts: lazy-load wrapper with type conversion
- Re-export DiskAnnIndex from core/index.ts
- Add @ruvector/diskann as optional peerDependency
- Update ADR-143: DiskANN fully implemented (not removed)

Co-Authored-By: claude-flow <ruv@ruv.net>
Algorithm details, optimization rationale, package architecture,
performance results (55µs search, 0.998 recall), and HNSW comparison.

Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit 844f20d

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
  Built from commit dbaef2e

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
* feat(musica): structure-first audio separation via dynamic mincut

Complete audio source separation system using graph partitioning instead
of traditional frequency-first DSP. 34 tests pass, all benchmarks validated.

Modules:
- stft: Zero-dep radix-2 FFT with Hann window and overlap-add ISTFT
- lanczos: SIMD-optimized sparse Lanczos eigensolver for graph Laplacians
- audio_graph: Weighted graph construction (spectral, temporal, harmonic, phase edges)
- separator: Spectral clustering via Fiedler vector + mincut refinement
- hearing_aid: Binaural streaming enhancer (<0.13ms latency, <8ms budget PASS)
- multitrack: 6-stem separator (vocals/bass/drums/guitar/piano/other)
- crowd: Distributed speaker identity tracker (hierarchical sensor fusion)
- wav: 16/24-bit PCM WAV I/O with binaural test generation
- benchmark: SDR/SIR/SAR evaluation with comparison baselines

Key results:
- Hearing aid: 0.09ms avg latency (87x margin under 8ms budget)
- Lanczos: Clean Fiedler cluster split in 4 iterations (16us)
- Multitrack: Perfect mask normalization (0.0000 sum error)
- WAV roundtrip: 0.000046 max quantization error

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* refactor(musica/crowd): use DynamicGraph for local + global graphs

Agent-improved crowd tracker using Gaussian-kernel similarity edges,
dense Laplacian spectral bipartition, and exponential moving average
embedding merging. All 34 tests pass.

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* enhance(musica/lanczos): add batch_lanczos with cross-frame alignment

Adds batch processing mode for computing eigenpairs across multiple
STFT windows with automatic Procrustes sign alignment between frames.

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* enhance(musica/hearing_aid): improve binaural pipeline with mincut refinement

Agent-enhanced hearing aid module adds dynamic mincut boundary refinement
via MinCutBuilder, temporal coherence bias, and improved speech scoring.

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* docs(musica): comprehensive README with benchmarks and competitive analysis

Detailed documentation covering all 9 modules, usage examples, benchmark
results, competitive positioning vs SOTA, and improvement roadmap.

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* feat(musica): add 6 enhancement modules — 55 tests passing

New modules:
- multi_res: Multi-resolution STFT (short/medium/long windows per band)
- phase: Griffin-Lim iterative phase estimation
- neural_refine: Tiny 2-layer MLP mask refinement (<100K params)
- adaptive: Grid/random/Bayesian graph parameter optimization
- streaming_multi: Frame-by-frame streaming 6-stem separation
- wasm_bridge: C-FFI WASM interface for browser deployment

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* feat(musica/wasm): add browser demo with drag-and-drop separation UI

Self-contained HTML+CSS+JS demo for WASM-based audio separation.
Dark theme, waveform visualization, Web Audio playback.

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* feat(musica): HEARmusica — Rust hearing aid DSP framework (Tympan port)

Complete hearing aid processing pipeline with 10 DSP blocks:
- BiquadFilter: 8 filter types (LP/HP/BP/notch/allpass/peaking/shelves)
- WDRCompressor: Multi-band WDRC with soft knee + attack/release
- FeedbackCanceller: NLMS adaptive filter
- GainProcessor: Audiogram fitting + NAL-R prescription
- GraphSeparatorBlock: Fiedler vector + dynamic mincut (novel)
- DelayLine: Sample-accurate circular buffer
- Limiter: Brick-wall output protection
- Mixer: Weighted signal combination
- Pipeline: Sequential block runner with latency tracking
- 4 preset configs: standard, speech-in-noise, music, max-clarity

ADR-143 documents architecture decisions.
87 tests passing.

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* feat(musica): 8-part benchmark suite + HEARmusica pipeline benchmarks

Part 7: HEARmusica pipeline — 4 presets benchmarked (0.01-0.75ms per block)
Part 8: Streaming 6-stem separation (0.35ms avg, 0.68ms max)
Updated README with benchmark results and 87-test / 11K-line stats.

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* feat(musica): add enhanced separator, evaluation module, and adaptive tuning

Complete the remaining optimization modules:
- enhanced_separator.rs: multi-res STFT + neural mask refinement pipeline with comparison report
- evaluation.rs: realistic audio signal generation (speech, drums, bass, noise) and full BSS metrics (SDR/SIR/SAR)
- Adaptive parameter tuning benchmark (Part 9) with random search
- Enhanced separator comparison (Part 10) across 4 modes
- Real audio evaluation (Part 11) across 4 scenarios
- WASM build verification script

100 tests passing, 11-part benchmark suite validated.

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* feat(musica): add candle-whisper transcription integration (ADR-144)

Pure-Rust speech transcription pipeline using candle-whisper:
- ADR-144: documents candle-whisper choice over whisper-rs (pure Rust, no C++ deps)
- transcriber.rs: Whisper pipeline with feature-gated candle deps, simulated
  transcriber for offline benchmarking, SNR-based WER estimation, resampling
- Part 12 benchmark: before/after separation quality for transcription
  across 3 scenarios (two speakers, speech+noise, cocktail party)
- 109 tests passing, 12-part benchmark suite validated

Enable with: cargo build --features transcribe

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* feat(musica): add real audio evaluation with public domain WAV files

- real_audio.rs: loads ESC-50, Signalogic speech, SampleLib music WAVs
- 6 real-world separation scenarios: speech+rain, male+female,
  music+crowd, birds+bells, speech+dog, speech+music
- Automatic resampling, mono mixing, SNR-controlled signal mixing
- Part 13 benchmark with per-scenario SDR measurement
- Download script (scripts/download_test_audio.sh) for test audio
- .gitignore for test_audio/ binary files
- 115 tests passing, 13-part benchmark suite

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* perf(musica): optimize critical hot loops across 5 modules

Profiler-guided optimizations targeting 2-3x cumulative speedup:
- stft.rs: reuse FFT buffers across frames (eliminates per-frame allocation)
- audio_graph.rs: cache frame base indices, precompute harmonic bounds
- separator.rs: K-means early stopping on convergence (saves ~15 iterations)
- lanczos.rs: selective reorthogonalization (full every 5 iters, partial otherwise)
- neural_refine.rs: manual loop for auto-vectorizable matrix multiply

115 tests passing.

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* feat(musica): add advanced SOTA separator with Wiener filtering, cascaded refinement, and multi-resolution fusion

Implements three techniques to push separation quality toward SOTA:
- Wiener filter mask refinement (M_s = |S_s|^p / sum_k |S_k|^p)
- Cascaded separation with iterative residual re-separation and decaying alpha blend
- Multi-resolution graph fusion across 256/512/1024 STFT windows
Part 14 benchmark compares basic vs advanced on 3 scenarios.

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* fix(musica): adaptive quality selection in advanced separator

Add permutation-invariant SDR evaluation, source alignment via
cross-correlation for multi-resolution fusion, and composite quality
metric (independence + reconstruction accuracy) for adaptive pipeline
selection. Advanced now consistently matches or beats basic: +3.0 dB
on well-separated, +1.5 dB on harmonic+noise.

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* feat(musica): add instantaneous frequency graph edges for close-tone separation

Add IF-based temporal edge weighting and cross-frequency IF edges.
Instantaneous frequency = phase advance rate across STFT frames.
Bins tracking the same sinusoidal component get stronger edges,
improving separation of close tones (400Hz+600Hz: +0.3 → +2.3 dB).

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* refactor(musica): best-of-resolutions strategy replaces lossy mask interpolation

Instead of interpolating masks between STFT resolutions (which
introduces artifacts), try each window size independently with
Wiener refinement, then pick the best by composite quality score.
Well-separated tones: +4.7 → +18.1 dB (+13.4 dB improvement).

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* feat(musica): multi-exponent Wiener search and energy-balanced quality metric

Try Wiener exponents 1.5/2.0/3.0 per resolution for broader search.
Add energy balance to quality score (penalizes degenerate partitions).
Close tones: consistently +1.4-1.8 dB over basic. 121 tests pass.

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* feat(musica): SOTA push — 8 major improvements across all modules

Quick wins:
- 8-bit and 32-bit WAV support in wav.rs (ESC-50 noise files now load)
- SDR variance reduction: seeded Fiedler init with 100 iterations

Core separation improvements:
- Multi-eigenvector spectral embedding: Lanczos k>2 eigenvectors
  with spectral k-means for multi-source separation
- Onset/transient detection edges: spectral flux onset detector
  groups co-onset bins for better drum/percussion separation
- Spatial covariance model: IPD/ILD-based stereo separation
  with far-field spatial model for binaural hearing aids

Research & benchmarking:
- Learned graph weights via Nelder-Mead simplex optimization
- MUSDB18 SOTA comparison framework with published results
  (Open-Unmix, Demucs, HTDemucs, BSRNN)
- Longer signal benchmarks (2-5s realistic duration)

Parts 15-17 added to benchmark suite. 131 tests pass.

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* feat(musica): terminal visualizer, weight optimization, multi-source separation

Add Part 18-20 to benchmark suite:
- Terminal audio visualizer (waveform, spectrum, masks, Lissajous, separation comparison)
  using ANSI escape codes and Unicode block characters, zero dependencies
- Nelder-Mead weight optimization benchmark with 3 training scenarios
- Multi-source (3+4 source) separation benchmark with permutation-invariant SDR
- Public evaluate_params wrapper for learned_weights module

276 tests passing (139 lib + 137 bin).

https://claude.ai/code/session_015KxNFsV5GQjQn6u9HbS9MK

* feat(musica): STFT padding, Lanczos batch improvements, WASM bridge cleanup

Improve STFT module with proper zero-padding and power-of-two FFT sizing.
Refactor Lanczos resampler batch processing and WASM bridge for clarity.
Clean up react_memo_cache_sentinel research files.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
  Built from commit 7d28bca

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
…lysis (#342)

Add deep research into three-axis KV cache compression:
- TriAttention (arXiv:2604.04921): trigonometric RoPE-based token sparsity, 10.7x
- Stacked compression: TriAttention × TurboQuant for ~50x KV reduction
- ADR-147: formal architecture decision with GOAP implementation plan

No published work combines these orthogonal methods. First-mover opportunity
for ruvLLM edge inference (128K context in 175MB on Pi 5).

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
  Built from commit 265aa68

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
Add optional RuVector field layer above the kernel and coherence engine.
Shells (Event/Pattern/Concept/Principle), geometric vs semantic antipodes,
multiplicative resonance, four-channel drift, routing hints as advisory
state. Aligned with the RuVix EPIC acceptance criteria — does not alter
v1 boot, witness, proof, or the 50 us coherence epoch budget.

- docs/research/ruvector-field/SPEC.md: full specification
- examples/ruvector-field: standalone std-only Rust demo (field_demo)
Replace the brief README with a complete crate overview: table of
contents, design principles, core concepts, architecture diagram,
API surface, scoring model, run instructions, annotated walkthrough
of the demo output, roadmap to production crates, and acceptance
gate. No code changes.
Replace vague promotion language in SPEC section 9 with a pinned
threshold table and formal hysteresis rules: minimum residence time
per shell, 4-cycle sliding hysteresis window, and an oscillation ban
that blocks nodes from crossing more than two shell boundaries inside
a single window.
…g, storage, policy

Moves the example crate from a flat types.rs / engine.rs / main.rs layout
into a domain-oriented library layout that implements the full SPEC.md.
Every public API now uses strongly typed newtypes (NodeId, EdgeId, HintId,
WitnessCursor, EmbeddingId) so ids cannot be confused at call sites.

New modules:
- model/: shell (with phi-scaled budgets), embedding + store interning,
  typed ids, node with axis history + promotion streak, edge.
- scoring/: multiplicative resonance, Laplacian effective-resistance-proxy
  coherence, candidate scoring with geometric-antipode novelty bonus,
  five-factor routing score with no hardcoded constants.
- storage/: SemanticIndex trait with LinearIndex default (HNSW seam),
  FieldSnapshot with diff, hour-keyed TemporalBuckets.
- policy/: AxisConstraint + PolicyRegistry with policy_fit / policy_risk.
- witness.rs: WitnessEvent covering the 9 events in SPEC section 14 plus
  WitnessLog with monotonic WitnessCursor and flush.
- proof.rs: ProofGate trait with NoopProofGate and ManualProofGate
  allowlist; RoutingHint::commit threads hints through the gate.
- embed.rs: EmbeddingProvider + deterministic HashEmbeddingProvider.
- clock.rs: Clock trait with SystemClock, TestClock, AtomicTestClock for
  thread-safe deterministic tests.
- error.rs: FieldError with 7 variants covering every fallible operation.

Cargo.toml becomes a library plus two binaries (field_demo and
acceptance_gate). Zero external dependencies.
…rift, routing

Implements the full engine orchestration over the restructured library:

- engine/mod.rs: FieldEngineConfig with hysteresis_window, min_residence_ns,
  drift threshold, promotion_passes, frontier_k. tick() recomputes
  Laplacian-proxy coherence, churn-based continuity, and updates axis
  scores based on retrieval selections and contradictions observed.
- engine/ingest.rs: ingest + add_edge + bind_semantic_antipode, each
  emitting exactly one witness event.
- engine/promote.rs: promotion with hysteresis (needs N consecutive passes
  AND min_residence_ns dwell time AND no oscillation in history window)
  plus demote_candidates for support decay / contradiction growth;
  returns PromotionRecord { node, from, to, reason: PromotionReason }.
- engine/retrieve.rs: shell-aware retrieval via SemanticIndex trait,
  full candidate scoring with geometric-antipode novelty bonus, 2-hop
  contradiction frontier walk scored by confidence * (1 - coherence),
  selection-count tracking for axis reinforcement, relative cutoff so
  low-value results do not consume the token budget.
- engine/drift.rs: four populated drift channels — semantic centroid
  shift, structural Jaccard over edge sets, policy fit delta, identity
  via node set difference — with the two-channel agreement rule.
- engine/route.rs: full routing formula with BFS partition distance,
  capability fit, role fit, shell fit, expected gain/cost; routes go
  through RoutingHint::commit and a ProofGate before emitting
  RoutingHintCommitted.

Temporal queries accept an optional time_window. Snapshots capture
shell centroids, contradiction frontier, drift, active hints and
witness cursor; diff returns SnapshotDiff.
Rewrites field_demo as a thin CLI over the restructured library. Supports
--nodes, --query, --shells, --show-witness, --show-drift/--no-drift,
--seed, and --help using only std::env::args. Every retrieval result,
routing hint, drift signal and field node is printed via its Display
impl, never {:?}. UTF-8 safe truncation uses chars().take(n).
README gains a section-10 file map and section-8 instructions for the
acceptance gate binary.
Adds 8 integration test files (21 tests total) covering every critical
spec invariant:

- resonance.rs — zero-factor collapse, unit-interval bounds, monotonicity.
- promotion.rs — single pass does not promote, N passes do, residence
  window enforcement, demotion on contradictions (uses AtomicTestClock).
- antipode.rs — symmetry of semantic antipode binding, geometric vs
  semantic separation.
- drift.rs — identical centroid -> zero semantic drift, orthogonal axes
  produce 0.5 semantic drift, agreement rule requires 2+ channels.
- retrieval.rs — disallowed shells excluded, explanation trace non-empty,
  contradiction frontier populated after antipode bind.
- phi_budget.rs — budget ratios exactly 1, 1/phi, 1/phi^2, 1/phi^3.
- witness.rs — every mutation emits one event, reads emit zero,
  bind_semantic_antipode and add_edge each emit exactly one event,
  flush drains.
- utf8.rs — multibyte node display truncates without panicking.

37 doc tests run from /// examples on every public struct and
FieldEngine method.

Adds benches/acceptance_gate.rs as a runnable bin implementing the
SPEC section 18 acceptance gate: seeds a 1350-node contradiction-heavy
corpus deterministically, runs 100 queries, measures contradiction
surfacing rate vs naive cosine, token cost improvement, long-session
coherence trend, and per-retrieve latency, then prints the four
numbers as a table with PASS/FAIL markers. No criterion dependency,
std-only.
Merge worktree-agent-a9f29d52. Closes all items from the "what's
left to improve" audit:

- Module split (lib + bin) with typed ids, errors, clock, proof gate
- Real Laplacian-proxy coherence; solver seam marked TODO(solver)
- Promotion hysteresis, demotion, oscillation ban; PromotionRecord
- Four-channel drift with agreement rule; RoutingHint full formula
- Witness log (9 events), ProofGate trait, policy registry
- Embedding store interning + HashEmbeddingProvider
- SemanticIndex trait + LinearIndex (HNSW seam marked TODO(hnsw))
- Temporal buckets, FieldSnapshot + diff, 2-hop contradiction frontier
- Display impls, CLI flags, UTF-8 safe truncate
- 21 integration tests + 37 doc-tests, zero warnings
- acceptance_gate benchmark: +50% contradiction surfacing,
  +43% retrieval token cost, +34% session coherence, ~305us latency
Add optional `solver` Cargo feature that routes local_coherence through
a Neumann-series iterative effective-resistance solver. The math is the
parallel-combined R_eff(c -> N) = 1/sum(w_i) on the center's star
subgraph, computed via a trait-based backend (SolverBackend) so a future
swap into a workspace-integrated ruvector-solver crate is a single impl.

Default build unchanged (std-only proxy). `cargo build --features solver`
compiles and `cargo test --features solver` passes all tests including
the new tests/feature_solver.rs gate.
Add optional `hnsw` Cargo feature providing a compact in-crate
Hierarchical Navigable Small World index behind the existing
SemanticIndex trait. Shell segmentation is inherited for free via a
HnswLayer per shell.

FieldEngine::with_hnsw_index() and new_with_hnsw() opt in. ingest,
promote, demote, and retrieve mirror writes to the HNSW index; retrieve
routes candidate generation through it when enabled. The acceptance_gate
binary picks up the feature automatically and reports contradiction
surfacing +70% vs +50% on the default build.

Default build unchanged. `cargo build --features hnsw` compiles and
`cargo test --features hnsw` passes including tests/feature_hnsw.rs.
Add optional `onnx-embeddings` Cargo feature providing a higher-quality
deterministic embedding provider. The shipped backend is a char n-gram
hashing provider (n=3, n=4) into 384 dims with L2 normalization,
matching the shape a real MiniLM ONNX embedding would produce so
downstream paths (HNSW, coherence solver, drift) see the same numerical
ranges a production backend would produce.

The seam is the existing EmbeddingProvider trait — a future ort-backed
provider is a drop-in replacement. Default build unchanged.
`cargo build --features onnx-embeddings` compiles and
`cargo test --features onnx-embeddings` passes.
Add an 'Optional features' subsection under 'Run the demo' listing
solver / hnsw / onnx-embeddings / full features, their target seams,
the build and test commands for each, and the acceptance gate
improvement numbers observed with HNSW enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants