From 5bdf0f50f12bc73dd0c870c31afd0b25de466b7e Mon Sep 17 00:00:00 2001 From: Cagdas Ucar Date: Tue, 30 Jun 2026 12:35:25 -0700 Subject: [PATCH 001/112] Wavefront footprints: coordinate-less corrections, drop stored levels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace channel-neighbor filtering with footprint adjacency — a bitset over base neurons — as the spatial-locality primitive. Corrections become coordinate-less; temporal votes resolve to base neurons via footprints before per-dimension consensus. Drop the stored temporal/spatial level fields and the Phase enum: a correction's depth is the wave's activation index. Temporal has no neighborhood (sequences against all active neurons); footprints are spatial-only and temporal corrections are footprint-less by design. Backup format changes accordingly (neurons.csv = id census; patterns.csv gains a spatial flag) and is not backward compatible with pre-footprint backups. Known cost: 14x14 static theta=0.9 explodes to ~2.9M neurons / ~2 img/s vs the channel-neighbor baseline's 32K / 186 img/s at accuracy parity (95.09% vs 94.88% held-out). Parked on this branch pending neuron reuse + refinement to absorb the explosion. Co-Authored-By: Claude Opus 4.8 --- apps/mnist/jobs/test.js | 8 +- apps/mnist/jobs/viz-footprints.js | 121 ++++ apps/stocks/jobs/multi-channel-test.js | 8 +- apps/stocks/jobs/test.js | 8 +- brain/brain-core/src/backup.rs | 71 +-- brain/brain-core/src/brain.rs | 196 +++--- brain/brain-core/src/footprint.rs | 243 ++++++++ brain/brain-core/src/lib.rs | 1 + brain/brain-core/src/memory.rs | 94 ++- brain/brain-core/src/thalamus.rs | 833 ++++++++++++++----------- brain/brain-core/src/types.rs | 9 - brain/brain-napi/index.d.ts | 37 +- brain/brain-napi/src/lib.rs | 48 +- docs/stock-demos.md | 62 +- 14 files changed, 1130 insertions(+), 609 deletions(-) create mode 100644 apps/mnist/jobs/viz-footprints.js create mode 100644 brain/brain-core/src/footprint.rs diff --git a/apps/mnist/jobs/test.js b/apps/mnist/jobs/test.js index 2cf1d1ce..acf094d8 100644 --- a/apps/mnist/jobs/test.js +++ b/apps/mnist/jobs/test.js @@ -542,7 +542,13 @@ export default class MNISTTestJob extends Job { const ips = (done / elapsed).toFixed(0); const pct = (done / total * 100).toFixed(1); const acc = (tally.correct / done * 100).toFixed(1); - process.stdout.write(`\r ${phase} ${done}/${total} (${pct}%) | ${acc}% acc | ${ips} img/s `); + // Live neuron count, cumulative mints, and per-level active-correction counts — the consolidation + // and hierarchy-depth signals during a long pass. Level counts reflect the last image's active set. + const summary = this.brain.getFrameSummary(); + const minted = this.brain.getSpatialCorrectionCount(); + const lc = this.brain.spatialLevelCounts(); + const levels = lc.length ? lc.map((c, i) => `L${i + 1}:${c}`).join(' ') : 'flat'; + process.stdout.write(`\r ${phase} ${done}/${total} (${pct}%) | ${acc}% acc | ${ips} img/s | ${summary.neuronCount} neurons (${minted} minted) | depth ${summary.maxSpatialLevel}: ${levels} `); } /** diff --git a/apps/mnist/jobs/viz-footprints.js b/apps/mnist/jobs/viz-footprints.js new file mode 100644 index 00000000..fafd7375 --- /dev/null +++ b/apps/mnist/jobs/viz-footprints.js @@ -0,0 +1,121 @@ +/** + * Visualize the spatial-correction hierarchy on a few 7×7 MNIST digits. + * + * Loads a trained brain, processes a sample image per digit, and renders each active spatial + * correction's footprint (the base pixels it covers) on the 7×7 grid — so we can see whether the + * L1/L2 patterns trace the digit's strokes rather than memorizing whole images. + * + * Usage: node apps/mnist/jobs/viz-footprints.js [--brain