Skip to content

Commit 9da4836

Browse files
author
Jan Hübener
committed
feat(.claude): polyglot notebook — single binary blackboard + scopes
1 parent 62f5574 commit 9da4836

2 files changed

Lines changed: 307 additions & 165 deletions

File tree

.claude/blackboard.md

Lines changed: 66 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -1,165 +1,66 @@
1-
# Project NDARRAY Expansion — Blackboard
2-
3-
> Shared state surface for all agents. Read before starting, update after completing work.
4-
5-
## Epoch: 4 — Cognitive Layer Migration
6-
## Global Goal: Port rustynum HPC features into ndarray fork
7-
8-
### Environment
9-
- rust_version: 1.94-stable
10-
- perf_target_blas: MKL (primary), OpenBLAS (alternative)
11-
- simd_level: AVX-512 (primary), AVX2 (fallback), SSE4.2 (minimum)
12-
13-
---
14-
15-
## Cognitive Layer Migration Status
16-
17-
### Core Types (Step 3a — rustynum-core)
18-
19-
| Module | Source | Status | Tests | Notes |
20-
|--------|--------|--------|-------|-------|
21-
| `hpc/fingerprint.rs` | `rustynum-core/fingerprint.rs` | ✅ Done | 12 pass | Const-generic `Fingerprint<N>`, XOR group, SIMD hamming via `bitwise.rs` |
22-
| `hpc/plane.rs` | `rustynum-core/plane.rs` | ✅ Done | 8 pass | 16384-bit i8 accumulator, L1 resident, 64-byte aligned |
23-
| `hpc/seal.rs` | `rustynum-core/seal.rs` | ✅ Done | 5 pass | Blake3 merkle verification (blake3 dep added) |
24-
| `hpc/node.rs` | `rustynum-core/node.rs` | ✅ Done | 6 pass | SPO cognitive atom, inline SplitMix64 RNG |
25-
| `hpc/cascade.rs` | `rustynum-core/hdr.rs` | ✅ Done | 5 pass | 3-stroke search + PackedDatabase + Welford drift |
26-
| `hpc/bf16_truth.rs` | `rustynum-core/bf16_hamming.rs` | ✅ Done | 8 pass | BF16 weights, awareness classify, PackedQualia |
27-
| `hpc/causality.rs` | `rustynum-core/causality.rs` | ✅ Done | 6 pass | CausalityDirection, NarsTruthValue, decomposition |
28-
| `hpc/blackboard.rs` | `rustynum-core/blackboard.rs` | ✅ Done | 10 pass | Zero-copy arena, 64-byte aligned, split-borrow API |
29-
30-
### Additional Crates (Step 3b)
31-
32-
| Module | Source | Status | Tests | Notes |
33-
|--------|--------|--------|-------|-------|
34-
| `hpc/bnn.rs` | `rustynum-bnn/bnn.rs` | ✅ Done | 6 pass | XNOR+popcount BNN inference, cascade search |
35-
| `hpc/clam.rs` | `rustynum-clam/` | ✅ Done | 7 pass | CLAM tree, rho_nn, knn_brute, XOR compression |
36-
| `hpc/arrow_bridge.rs` | `rustynum-arrow/` | ✅ Done | 5 pass | ThreePlaneFingerprintBuffer, SoakingBuffer, GateState |
37-
38-
### Infrastructure
39-
40-
| Item | Status | Notes |
41-
|------|--------|-------|
42-
| Agent definitions (4) | ✅ Done | cognitive-architect, cascade-architect, truth-architect, migration-tracker |
43-
| Knowledge docs (5) | ✅ Done | plane_node_seal, cascade_search, bf16_truth, hardware_map, constants |
44-
| Prompts transcoded (5) | ✅ Done | 01_clam_qualiacam, 02_crystal_encoder, 03_lance_schema, 04_lance_graph, 05_cross_repo |
45-
| `Cargo.toml` blake3 dep | ✅ Done | `blake3 = "1"` |
46-
| `hpc/mod.rs` declarations | ✅ Done | 11 new modules with `#[allow(missing_docs)]` |
47-
48-
### Test Summary (STALE — see audit below)
49-
- ~~**286 lib tests passing** (209 original + 77 new cognitive layer tests)~~**880 lib tests passing** (2026-03-22 audit)
50-
- **Clippy clean** (`cargo clippy -- -D warnings`)
51-
- ~~**All doctests passing**~~**2 doctest failures** out of 302
52-
53-
---
54-
55-
## Epoch 4 Completion Status (2026-03-22 Audit)
56-
57-
> The original blackboard test counts and "must be ported" checklist were massively stale.
58-
> Every module has significantly more tests than originally documented. All porting work is complete.
59-
60-
### HPC Module Inventory (55 files in src/hpc/)
61-
62-
**Core types (Step 3a)** — all DONE, test counts grew:
63-
| Module | Original claim | Actual tests |
64-
|--------|---------------|-------------|
65-
| fingerprint.rs | 12 | 12 |
66-
| plane.rs | 8 | 16 |
67-
| seal.rs | 5 | 4 |
68-
| node.rs | 6 | 9 |
69-
| cascade.rs | 5 | 12 |
70-
| bf16_truth.rs | 8 | 23 |
71-
| causality.rs | 6 | 17 |
72-
| blackboard.rs | 10 | 36 |
73-
74-
**Additional crates (Step 3b)** — all DONE:
75-
| Module | Original claim | Actual tests |
76-
|--------|---------------|-------------|
77-
| bnn.rs | 6 | 26 |
78-
| clam.rs | 7 | 46 |
79-
| arrow_bridge.rs | 5 | 26 |
80-
81-
**BLAS / Numerical** — ALL DONE:
82-
- blas_level1.rs (11 tests), blas_level2.rs (10), blas_level3.rs (5)
83-
- fft.rs (3), lapack.rs (4), vml.rs (5), statistics.rs (11), quantized.rs (7), activations.rs (9)
84-
85-
**Cognitive / Search / Advanced** — ALL DONE (27 additional modules, ~469 tests):
86-
- nars, qualia, qualia_gate, hdc, spo_bundle, cogrecord, graph, merkle_tree
87-
- cam_index, prefilter, clam_search, clam_compress, parallel_search
88-
- crystal_encoder, deepnsm, dn_tree, organic, substrate, tekamolo, vsa
89-
- bnn_cross_plane, bnn_causal_trajectory, binding_matrix
90-
- bgz17_bridge, palette_distance, layered_distance, surround_metadata
91-
- compression_curves, cyclic_bundle, packed, bitwise, kernels, udf_kernels, projection
92-
93-
### Backend Module (6 files in src/backend/)
94-
- BlasFloat trait dispatch: DONE (mod.rs, native.rs)
95-
- MKL FFI: DONE (mkl.rs)
96-
- OpenBLAS FFI: DONE (openblas.rs)
97-
- SIMD compat layer: DONE (simd.rs, simd_avx512.rs, simd_avx2.rs — LazyLock<Tier> AVX-512/AVX2/Scalar)
98-
- AVX-512 kernels: DONE (kernels_avx512.rs)
99-
100-
### Build Status
101-
- Build currently fails (exit 101) — needs investigation
102-
- 880 lib tests pass when build succeeds
103-
- 2 doctest failures out of 302:
104-
- `src/hpc/crystal_encoder.rs` line 251 — `distill` doctest (compile error)
105-
- `src/hpc/udf_kernels.rs` line 200 — `udf_sigma_classify` doctest (assertion: `"noise" != "exact"`)
106-
107-
### Architecture Notes
108-
- `LinalgBackend` trait from CLAUDE.md spec → actual impl is `BlasFloat` trait (different name, same purpose)
109-
- `src/simd/` directory from spec → actual is `src/simd.rs`, `src/simd_avx512.rs`, `src/simd_avx2.rs` (three top-level files)
110-
- `src/vector/` directory from spec → not created (functionality in hpc/)
111-
- Blackboard uses `HashMap<String, Box<dyn Any>>`, not a true 64-byte aligned arena
112-
113-
---
114-
115-
## Stage 0: Gap Analysis
116-
117-
### Already exists in ndarray:
118-
- [x] Array constructors: zeros, ones, range, linspace, logspace, geomspace
119-
- [x] Element-wise float math: exp, ln, sqrt, sin, cos, tan, abs, floor, ceil, round, etc.
120-
- [x] Dot product (general_mat_mul, general_mat_vec_mul, Dot trait)
121-
- [x] Sum, product, mean (impl_numeric.rs)
122-
- [x] Views: ArrayView, ArrayViewMut, slicing, strides
123-
- [x] Transpose, reshape (via into_shape), swap_axes
124-
- [x] Concatenate, stack (stacking.rs)
125-
- [x] Broadcasting (built-in)
126-
- [x] Clamp
127-
- [x] **Bitwise**: hamming_distance, popcount, hamming_distance_batch (VPOPCNTDQ dispatch wired)
128-
- [x] **SIMD binary**: hamming_batch, hamming_top_k (VPOPCNTDQ + raw-slice API)
129-
- [x] **Cognitive layer**: Fingerprint, Plane, Node, Seal, Cascade, BF16Truth, Causality, Blackboard, BNN, CLAM, ArrowBridge
130-
131-
### Must be ported from rustynum (ALL DONE as of 2026-03-22):
132-
- [x] **Backend trait** (BlasFloat — renamed from LinalgBackend) — src/backend/mod.rs + native.rs
133-
- [x] **BLAS L1** — hpc/blas_level1.rs (11 tests)
134-
- [x] **BLAS L1 SIMD** — hpc/blas_level1.rs (ScalarArith + VecArith traits)
135-
- [x] **BLAS L2** — hpc/blas_level2.rs (10 tests)
136-
- [x] **BLAS L3** — hpc/blas_level3.rs (5 tests)
137-
- [x] **BF16 GEMM** — hpc/quantized.rs (7 tests)
138-
- [x] **Int8 GEMM** — hpc/quantized.rs
139-
- [x] **LAPACK** — hpc/lapack.rs (4 tests)
140-
- [x] **FFT** — hpc/fft.rs (3 tests)
141-
- [x] **VML** — hpc/vml.rs (5 tests)
142-
- [x] **Statistics** — hpc/statistics.rs (11 tests)
143-
- [x] **Array ops** — hpc/statistics.rs + hpc/activations.rs (9 tests)
144-
- [x] **HDC** — hpc/hdc.rs (5 tests)
145-
- [x] **Projection** — hpc/projection.rs (4 tests)
146-
- [x] **CogRecord** — hpc/cogrecord.rs (4 tests)
147-
- [x] **Graph** — hpc/graph.rs (4 tests)
148-
- [x] **Binding matrix** — hpc/binding_matrix.rs (9 tests)
149-
150-
---
151-
152-
## Strategic Analysis
153-
<!-- l3-strategist writes here -->
154-
- Phase 1 (Stages 1-4): Core BLAS — highest impact, enables all downstream
155-
- Phase 2 (Stages 5-6): LAPACK/FFT/VML + Array ops — ML-ready
156-
- Phase 3 (Stages 7-8): HDC/CogRecord — domain-specific
157-
- Phase 4 (Stages 9-10): QA + docs — ship-ready
158-
159-
---
160-
161-
## Architecture Decisions
162-
<!-- savant-architect writes here -->
163-
- LinalgBackend trait: generic monomorphized (no Box<dyn> in hot paths)
164-
- SIMD dispatch: runtime detection via is_x86_feature_detected!
165-
- Feature gates: native (default), intel-mkl, openblas — mutu
1+
# Polyglot Notebook — Single Binary Architecture
2+
3+
## The Binary
4+
5+
One `cargo build`. Ships as one executable. Contains:
6+
7+
```
8+
reactive runtime (transcoded from marimo Python)
9+
graph query engines (transcoded from graph-notebook Python)
10+
kernel protocol (Rust-native ZMQ, from kernel-protocol spec)
11+
document publisher (transcoded from quarto TS/Deno)
12+
local graph database (lance-graph, already Rust)
13+
SIMD kernels (ndarray, already Rust)
14+
graph compiler (rs-graph-llm, already Rust)
15+
web frontend (marimo's JS/React, served by the binary)
16+
```
17+
18+
External process: R only (Bardioc/almato). Speaks Arrow IPC to the binary.
19+
20+
## Repos → Crates
21+
22+
| Repo (source) | Becomes | Work |
23+
|------|---------|------|
24+
| marimo | `crate::runtime` + `crate::server` | Transcode Python→Rust |
25+
| graph-notebook | `crate::query::{cypher,gremlin,sparql,nars}` | Transcode Python→Rust |
26+
| kernel-protocol | `crate::kernel` | Implement from spec in Rust |
27+
| quarto | `crate::publish` | Transcode TS→Rust |
28+
| quarto-r | external R process | Stays R, Arrow IPC bridge |
29+
| lance-graph | `crate::graph` | Already Rust, integrate |
30+
| ndarray | `crate::simd` + `crate::linalg` | Already Rust, integrate |
31+
| rs-graph-llm | `crate::compiler` | Already Rust, fix build |
32+
33+
## Scopes (parallel, non-overlapping)
34+
35+
### SCOPE A: Reactive Runtime (marimo → Rust)
36+
Transcode marimo's reactive cell execution model to Rust.
37+
The core insight: cells have dependencies, when a cell's input changes,
38+
downstream cells re-execute. That's a DAG scheduler — natural in Rust.
39+
40+
### SCOPE B: Query Engines (graph-notebook → Rust)
41+
Transcode graph-notebook's Cypher/Gremlin/SPARQL executors to Rust.
42+
Bolt protocol client, WebSocket client, HTTP client — all Rust-native.
43+
Add local path: Cypher → lance-graph semiring (no network).
44+
45+
### SCOPE C: Kernel Protocol (kernel-protocol spec → Rust)
46+
Implement Jupyter kernel wire protocol in Rust.
47+
Only needed for R (IRkernel) — everything else runs in-process.
48+
ZMQ via zeromq-rs. Connection file parsing. Message ser/de.
49+
50+
### SCOPE D: Publisher (quarto TS → Rust)
51+
Transcode Quarto's document rendering pipeline to Rust.
52+
Pandoc AST manipulation. Markdown → PDF/HTML.
53+
Custom graph visualization extension.
54+
55+
### SCOPE E: Integration (lance-graph + ndarray + rs-graph-llm)
56+
Wire the existing Rust crates into the binary.
57+
Fix rs-graph-llm build. SIMD kernels for graph ops.
58+
This is mostly Cargo.toml workspace wiring + API surface.
59+
60+
## Decisions
61+
[DECISION] One binary, no Python runtime
62+
[DECISION] marimo's JS frontend served by Rust HTTP server (axum/actix)
63+
[DECISION] R is the ONLY external process (Arrow IPC bridge)
64+
[DECISION] Cypher executes locally via lance-graph semiring by default
65+
[DECISION] Remote DB connections (Neo4j, FalkorDB) via native Bolt client
66+
[DECISION] vis.js graph rendering served as static assets by the binary

0 commit comments

Comments
 (0)