|
1 | 1 | // SPDX-License-Identifier: PMPL-1.0-or-later |
2 | | -= NeuroPhone - Neurosymbolic AI Android Application — Show Me The Receipts |
| 2 | +// SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk> |
| 3 | += NeuroPhone — Neurosymbolic AI Android Application — Show Me The Receipts |
3 | 4 | :toc: |
4 | 5 | :icons: font |
5 | 6 |
|
6 | | -The README makes claims. This file backs them up. |
| 7 | +The README makes claims. This file backs them up. For each headline feature: |
| 8 | +what makes it work, where the code is, and an honest caveat. |
| 9 | + |
| 10 | +== Claim: On-device spiking neural networks + local LLM pipeline |
| 11 | + |
| 12 | +[quote, README] |
| 13 | +____ |
| 14 | +neurophone is a complete Android application for neurosymbolic AI on mobile |
| 15 | +devices. It combines spiking neural networks with large language models for |
| 16 | +on-device intelligence. Processes: Sensor data → Neural interpretation → LLM query. |
| 17 | +Runs on the device, with cloud fallback. |
| 18 | +____ |
| 19 | + |
| 20 | +The pipeline is implemented as eight Rust crates under `crates/`. The critical |
| 21 | +path runs: `sensors` crate collects accelerometer, gyroscope, magnetometer, light |
| 22 | +and proximity readings at 50Hz with IIR filtering → `lsm` crate feeds the |
| 23 | +filtered readings into a 512-neuron Leaky Integrate-and-Fire grid (8×8×8, |
| 24 | +distance-dependent connectivity, 1kHz processing) → `esn` crate runs a |
| 25 | +300-neuron Echo State Network with spectral radius 0.95 for state prediction |
| 26 | +→ `bridge` crate integrates LSM and ESN states into a natural-language context |
| 27 | +string for the LLM → `llm` crate runs Llama 3.2 1B/3B via llama.cpp with |
| 28 | +Q4_K_M quantization. The `neurophone-core` crate orchestrates the async loop |
| 29 | +via `NeuroSymbolicSystem::start()`, accepting sensor data via |
| 30 | +`system.send_sensor(reading).await` and answering queries via |
| 31 | +`system.query("What's happening?", prefer_local).await`. |
| 32 | + |
| 33 | +**Caveat:** The JNI bridge (`neurophone-android` crate) requires Android NDK 26+ |
| 34 | +and the Android app (`android/` directory) currently uses Kotlin for the |
| 35 | +JNI interface and Compose UI — this is an acknowledged exception in an |
| 36 | +otherwise Kotlin-banned account, because Android JNI without Kotlin is |
| 37 | +significantly more complex. The migration path toward Tauri 2.0 / Dioxus is |
| 38 | +documented in the README. Also, Llama model download (~700MB) is a manual |
| 39 | +step; there is no in-app model downloader yet. |
| 40 | + |
| 41 | +- Core orchestration: `crates/neurophone-core/src/` |
| 42 | +- LSM: `crates/lsm/src/` |
| 43 | +- ESN: `crates/esn/src/` |
| 44 | +- Bridge: `crates/bridge/src/` |
| 45 | +- LLM client: `crates/llm/src/` |
| 46 | +- Android JNI: `crates/neurophone-android/src/` |
| 47 | +- Android app: `android/app/src/main/java/ai/neurophone/` |
| 48 | + |
| 49 | +== Claim: AI-assisted installation — point an AI at the repo URL and it handles everything |
7 | 50 |
|
8 | 51 | [quote, README] |
9 | 52 | ____ |
10 | | -It reads this repo, asks a few questions, and does everything. <<ai-install,Details below>>. |
| 53 | +You don't need to read this README. Just say this to any AI assistant: |
| 54 | +"Set up NeuroPhone on my Android from https://github.com/hyperpolymath/neurophone" |
| 55 | +The AI fetches this repo, reads the installation guide inside it, figures out |
| 56 | +your device, and does everything. |
11 | 57 | ____ |
12 | 58 |
|
13 | | -== Technology Choices |
| 59 | +The mechanism is `docs/AI_INSTALLATION_GUIDE.adoc`, which is a structured, |
| 60 | +machine-readable step-by-step recipe. It covers: Termux installation (F-Droid |
| 61 | +path only — not Play Store), Rust toolchain setup, repository clone, |
| 62 | +`./scripts/build-android.sh` execution, model download via `adb push`, and |
| 63 | +config generation. The guide is written so that an AI with web-read or repo-read |
| 64 | +capability can execute it procedurally. The `scripts/setup.sh` and |
| 65 | +`scripts/build-android.sh` scripts do the actual heavy lifting; the |
| 66 | +AI-installation claim is a UX wrapper around them. |
| 67 | + |
| 68 | +**Caveat:** The AI-installation path requires an AI that can execute shell |
| 69 | +commands or generate them accurately for the user's device. It is not a |
| 70 | +magic one-click install — it is a structured handoff. Devices other than |
| 71 | +Oppo Reno 13 (the primary target, MediaTek Dimensity 8350, 12GB RAM) will |
| 72 | +need thread-count and model-size adjustments that the guide parametrises |
| 73 | +but which the AI must apply correctly. |
| 74 | + |
| 75 | +- AI guide: `docs/AI_INSTALLATION_GUIDE.adoc` |
| 76 | +- Build scripts: `scripts/setup.sh`, `scripts/build-android.sh` |
| 77 | +- Config template: `config/default.toml` |
| 78 | + |
| 79 | +== Dogfooded Across The Account |
14 | 80 |
|
15 | 81 | [cols="1,2"] |
16 | 82 | |=== |
17 | | -| Technology | Learn More |
| 83 | +| Technology | Also Used In |
| 84 | + |
| 85 | +| **Rust (multi-crate workspace)** | https://github.com/hyperpolymath/project-wharf[project-wharf], |
| 86 | + https://github.com/hyperpolymath/protocol-squisher[protocol-squisher], |
| 87 | + https://github.com/hyperpolymath/ephapax[ephapax] (17 crates), |
| 88 | + https://github.com/hyperpolymath/burble[burble] |
| 89 | +| **Cargo.toml workspace layout** | https://github.com/hyperpolymath/ephapax[ephapax], |
| 90 | + https://github.com/hyperpolymath/protocol-squisher[protocol-squisher], |
| 91 | + https://github.com/hyperpolymath/raze-tui[raze-tui] |
| 92 | +| **Claude API fallback pattern** | The cloud-fallback via `crates/claude-client/` |
| 93 | + mirrors the pattern used in https://github.com/hyperpolymath/maa-framework[maa-framework] |
| 94 | + and https://github.com/hyperpolymath/boj-server[boj-server] |
| 95 | +| **llama.cpp / local LLM** | Pattern shared with |
| 96 | + https://github.com/hyperpolymath/neurophone[neurophone] as the primary |
| 97 | + account experiment in on-device inference |
| 98 | +|=== |
| 99 | + |
| 100 | +== File Map |
| 101 | + |
| 102 | +[cols="1,3"] |
| 103 | +|=== |
| 104 | +| Path | What's There |
| 105 | + |
| 106 | +| `Cargo.toml` |
| 107 | +| Workspace root. Declares all eight member crates and shared dependency versions. |
18 | 108 |
|
19 | | -| **Rust** | https://www.rust-lang.org |
| 109 | +| `crates/lsm/` |
| 110 | +| Liquid State Machine. 512 LIF neurons in 8×8×8 grid. Distance-weighted |
| 111 | + connectivity. Spike processing at 1kHz. Key type: `LiquidStateMachine`. |
| 112 | + |
| 113 | +| `crates/esn/` |
| 114 | +| Echo State Network. 300-neuron reservoir, spectral radius 0.95, leaky integrator |
| 115 | + dynamics, ridge regression output. Key type: `EchoStateNetwork`. |
| 116 | + |
| 117 | +| `crates/sensors/` |
| 118 | +| Android sensor abstraction. Reads accelerometer, gyroscope, magnetometer, |
| 119 | + light, proximity via Android Sensor API (through JNI). IIR filters at 50Hz. |
| 120 | + |
| 121 | +| `crates/bridge/` |
| 122 | +| Neural-to-symbolic translation. Takes LSM + ESN state vectors and produces |
| 123 | + natural language context strings injected into LLM prompts. |
| 124 | + Key function: `encode_neural_state()`. |
| 125 | + |
| 126 | +| `crates/llm/` |
| 127 | +| On-device LLM inference via llama.cpp bindings. Handles model loading, |
| 128 | + Q4_K_M quantization, streaming token output, and neural context injection. |
| 129 | + |
| 130 | +| `crates/claude-client/` |
| 131 | +| Cloud fallback. Claude Messages API with retry/backoff. Activated when |
| 132 | + `prefer_local=false` or when LSM confidence is below threshold. |
| 133 | + |
| 134 | +| `crates/neurophone-core/` |
| 135 | +| Top-level orchestrator. `NeuroSymbolicSystem` manages the async event loop |
| 136 | + connecting sensors → LSM → ESN → bridge → LLM. Entry: `start()`. |
| 137 | + |
| 138 | +| `crates/neurophone-android/` |
| 139 | +| JNI bridge crate. Exposes `init()`, `start()`, `stop()`, `query()`, and |
| 140 | + `get_neural_context()` to Kotlin via `NativeLib.kt`. |
| 141 | + |
| 142 | +| `android/` |
| 143 | +| Android app. `MainActivity.kt`, `NativeLib.kt` (JNI declarations), |
| 144 | + `SensorManager.kt`, Compose UI in `ui/`. |
| 145 | + |
| 146 | +| `config/default.toml` |
| 147 | +| Runtime configuration. Claude API key, Llama model path, thread count, |
| 148 | + context size, cloud fallback threshold. |
| 149 | + |
| 150 | +| `scripts/setup.sh` |
| 151 | +| Environment setup: installs Rust, Android NDK, cross-compilation targets. |
| 152 | + |
| 153 | +| `scripts/build-android.sh` |
| 154 | +| Builds all Rust crates for Android ARM64 and copies `.so` files to |
| 155 | + `android/app/src/main/jniLibs/`. |
| 156 | + |
| 157 | +| `docs/AI_INSTALLATION_GUIDE.adoc` |
| 158 | +| Machine-readable AI-assisted installation recipe. |
| 159 | + |
| 160 | +| `benches/` |
| 161 | +| Criterion benchmarks for LSM and ESN step performance. |
| 162 | + |
| 163 | +| `fuzz/` |
| 164 | +| Cargo-fuzz targets for sensor input fuzzing. |
| 165 | + |
| 166 | +| `.machine_readable/6a2/` |
| 167 | +| A2ML checkpoint files: STATE, META, ECOSYSTEM, AGENTIC, NEUROSYM, PLAYBOOK. |
20 | 168 | |=== |
21 | 169 |
|
22 | | -== Questions? |
| 170 | +== Checking It |
| 171 | + |
| 172 | +[source,bash] |
| 173 | +---- |
| 174 | +# Run unit tests (host) |
| 175 | +cargo test |
| 176 | +
|
| 177 | +# Build for Android |
| 178 | +./scripts/build-android.sh |
| 179 | +
|
| 180 | +# Run benchmarks |
| 181 | +cargo bench |
23 | 182 |
|
24 | | -Open an issue or reach out directly — happy to explain anything in more detail. |
| 183 | +# Generate API docs |
| 184 | +cargo doc --open |
| 185 | +---- |
0 commit comments