Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .claude/SURGERY_BLACKBOARD.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Brain Surgery Blackboard — Session State

## Audit Status (2026-03-22)

- All 25 tasks across 5 roles (Surgeon, Locksmith, Bridge, Bouncer, Seal) remain PENDING — 0/25 completed
- server.rs (3717 lines) still uses CogRedis directly, not RedisAdapter
- P1 (src/query/cypher.rs) and P3 (src/query/lance_parser/) still exist — deletion tasks not started
- SPO module promoted to src/spo/ (18 files) — DONE
- SPO Merkle hardening — DONE
- 16K-bit container — DONE
- Graph SPO on BindSpace (src/graph/spo/) — PARTIAL (9 files, disconnected from server)
- Awareness loop — NOT STARTED (no awareness_loop files found)
- Path dependencies: 11 path deps, compilation requires all siblings present

session_id: "brain-surgery-2026-03"
started: "2026-03-12"
orchestration_prompt: ".claude/prompts/18_brain_surgery_orchestration.md"
Expand Down Expand Up @@ -44,3 +56,24 @@ decisions_made: []
notes: |
Read .claude/prompts/18_brain_surgery_orchestration.md for full context.
Read prompts 15, 16, 17, 17a BEFORE starting any work.

## Integration Plan Reference (2026-03-22)

The brain surgery tasks are now sequenced within the master integration plan.
They fall under **Plateau 2, Phase 2C** — only executed AFTER rustynum→ndarray
migration (2A) and lance-graph wiring (2B) are stable.

**Pre-conditions for surgery:**
- ndarray builds and tests pass (Plateau 0)
- ladybug-rs compiles with ndarray (Phase 2A)
- P1/P3 dead code deleted (Phase 2B.1-2B.2)
- lance-graph Cypher works end-to-end through server.rs (Phase 2B.4)

**Surgery task dependencies on integration phases:**
- S1/S2 (delete P1/P3): Unblocked → moved to Phase 2B.1/2B.2
- L1-L5 (crystal API, codebook, truth): Blocked on Phase 2A.4 (ndarray types)
- B1-B5 (wire SPO to server): Blocked on Phase 2B.5 (lance-graph SPO backend)
- N1-N5 (cargo deps, dedup): Blocked on Phase 2B.4 (lance-graph Cypher)
- K1-K5 (UDF, query seal): Blocked on Phase 2B.6 (server.rs rewire)

See: /home/user/INTEGRATION_PLAN.md
35 changes: 33 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ ladybug-rs CANNOT compile alone. It depends on sibling repos via relative paths:
```
REQUIRED (clone alongside ladybug-rs):
../rustynum/ rustynum-rs, rustynum-core, rustynum-bnn, rustynum-arrow,
rustynum-holo, rustynum-clam
rustynum-holo, rustynum-clam [MIGRATING → ndarray]
../ndarray/ AdaWorldAPI/ndarray fork — HPC compute (Plateau 2 migration target)
../crewai-rust/ crewai-vendor (feature-gated behind "crewai")
../n8n-rs/ n8n-core, n8n-workflow, n8n-arrow, n8n-grpc, n8n-hamming
```
Expand Down Expand Up @@ -109,7 +110,7 @@ There is no `fn cold_to_hot()`. Their absence IS the architecture.

```
ladybug-rs role: "The Brain" in the four-repo architecture.
rustynum = The Muscle (SIMD substrate)
rustynum = The Muscle (SIMD substrate) [MIGRATING → ndarray, see INTEGRATION_PLAN.md]
ladybug-rs = The Brain (BindSpace, SPO, server) ← THIS REPO
staunen = The Bet (6 instructions, no GPU)
lance-graph = The Face (Cypher/SQL query surface)
Expand Down Expand Up @@ -152,6 +153,36 @@ cargo build --bin ladybug-server

---

## 8. Migration: rustynum → ndarray (Plateau 2)

ladybug-rs currently depends on 6 rustynum crates for SIMD compute. These are being
superseded by `AdaWorldAPI/ndarray` (fork with 55 HPC modules, 880 tests).

**What changes:**
- `rustynum::Fingerprint` → `ndarray::hpc::fingerprint::Fingerprint<256>`
- `rustynum::hamming_distance` → `ndarray::hpc::bitwise::hamming_distance_raw`
- `rustynum::TruthValue` → `ndarray::hpc::bf16_truth::BF16Truth`
- `rustynum::Cascade` → `ndarray::hpc::cascade::Cascade`
- BLAS L1-3: `rustyblas::*` → `ndarray::hpc::blas_level{1,2,3}::*`

**What also changes:**
- lance-graph becomes the Cypher/graph query surface (replacing P1/P3 dead code)
- lance-graph semiring algebra replaces ad-hoc graph ops in src/graph/spo/
- rs-graph-llm becomes the orchestration layer (replacing direct crewAI integration)

**Migration order** (from INTEGRATION_PLAN.md Plateau 2):
1. Add ndarray as path dep (alongside rustynum, not replacing)
2. Create compat bridge (src/compat/ndarray_bridge.rs)
3. Migrate src/spo/ to ndarray types — CHECKPOINT: cargo check
4. Migrate src/nars/ to ndarray types
5. Migrate src/storage/ BindSpace — CHECKPOINT: cargo test
6. Remove rustynum deps — only after all tests pass

**DO NOT** start this migration before ndarray builds clean (Plateau 0).
**DO NOT** migrate BindSpace and SPO simultaneously — SPO first, then BindSpace.

---

## Session Documents (read in order for full context)

```
Expand Down
28 changes: 13 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ bench = [] # Benchmark suite (comparison vs Qdrant/Milvus)
flight = ["arrow-flight", "tonic", "prost"] # Arrow Flight MCP server
crewai = ["flight"] # crewAI orchestration (A2A, agent cards, thinking templates)
json_fallback = [] # Legacy JSON MCP types (backwards compat)
# rustynum is OBLIGATORY — always included. Feature kept for test isolation only.
rustynum = []
# ndarray replaces rustynum (2026-03-22). Feature kept for test isolation only.
ndarray-hpc = []

# vendor-n8n and vendor-crewai are OBLIGATORY — always included.
# Feature flags kept as no-ops for backwards compatibility only.
Expand Down Expand Up @@ -201,24 +201,22 @@ n8n-hamming = { path = "../n8n-rs/n8n-rust/crates/n8n-hamming" }
crewai-vendor = { package = "crewai", path = "../crewai-rust" }

# -----------------------------------------------------------------------------
# Vendor: rustynum-rs (SIMD numerical library with AVX-512 VPOPCNTDQ + VNNI)
# Source: https://github.com/AdaWorldAPI/rustynum
# Vendor: ndarray (AdaWorldAPI fork with 55 HPC modules, replaces rustynum)
# Source: https://github.com/AdaWorldAPI/ndarray
# Provides runtime-dispatched kernels:
# - VPOPCNTDQ popcount/hamming (8× speedup over scalar POPCNT)
# - VNNI VPDPBUSD int8 dot product (64× speedup for embeddings)
# - Optimized bundle (ripple-carry > per-bit counting)
# - GEMM for batch operations
# - VPOPCNTDQ popcount/hamming via hpc::bitwise
# - VNNI int8 dot product via simd_avx2::dot_i8
# - Majority-vote bundle via hpc::hdc::HdcOps
# - BNN causal trajectory, cross-plane, shift detection
# - SigmaGate, CollapseGate, SignificanceLevel
# - Zero-copy Container bridge: view_u64_as_bytes()
# Requires: stable Rust 1.93+ (AVX-512 intrinsics stabilized in 1.89)
# Requires: stable Rust 1.93+
# OBLIGATORY — always included, not behind a feature gate.
# Uses sibling directory locally, vendor/ in Docker.
# -----------------------------------------------------------------------------
rustynum-rs = { path = "../rustynum/rustynum-rs" }
rustynum-core = { path = "../rustynum/rustynum-core", features = ["avx512"] }
rustynum-bnn = { path = "../rustynum/rustynum-bnn", features = ["avx512"] }
rustynum-arrow = { path = "../rustynum/rustynum-arrow", default-features = false, features = ["arrow"] }
rustynum-holo = { path = "../rustynum/rustynum-holo", features = ["avx512"] }
rustynum-clam = { path = "../rustynum/rustynum-clam", features = ["avx512"] }
ndarray = { path = "../ndarray" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update automation to fetch the new ndarray sibling

Switching Cargo to ndarray = { path = "../ndarray" } breaks every automated build path that still provisions only ../rustynum//rustynum. For example, .github/workflows/ci-master.yml:33-39, .github/workflows/proof.yml:60-66, and Dockerfile.release:57-68 all clone rustynum but never create the sibling path Cargo now resolves, so CI and release-image builds will fail before compilation with a missing path dependency.

Useful? React with 👍 / 👎.


# All rustynum dependencies removed (2026-03-22). ndarray replaces everything.

# =============================================================================
# DEV DEPENDENCIES
Expand Down
Loading
Loading