Fruit-fly connectome circuits compiled into edge controllers, in Python, WebAssembly and zero-heap ANSI C99
Six open-source libraries. Five of them run weight matrices compiled from the 157,789-neuron adult Drosophila BANC v888 connectome inside hand-designed dynamics — including a 4-organ reflex controller plus MAVLink v2 in 24 KB of zero-float ANSI C99 RAM (107.5 KB standalone WASM) — tested against degree-preserving shuffled wiring. Plus loss-healing NLTP transport. Research beta.
Website & Live WASM Simulator · Products · v3.0.0 results · Install · Repository layout · Development
Products
Each product takes one subsystem of the adult fruit-fly nervous system (BANC v888: 157,789 proofread neurons, 23.55M synapses) and compiles its circuit into weight matrices for a standalone library. NeckLink CNS combines the four sensory-motor organs into one 24 KB reflex controller. Every product ships on PyPI with a zero-heap, zero-float ANSI C99 core and an Arduino/ESP32 library (compiled with the ESP32 toolchain; NLTP is also hardware-tested on ESP32/ESP8266). Every connectome-driven class also offers connectome_weights="v2_analytic", the earlier hand-tuned symmetric model.
| Product | Fly circuit (BANC v888) |
What it does | Package |
|---|---|---|---|
NeckLink CNS (v3.0.0) |
Brain → descending neurons → leg motor pools (10×11, 6×10) |
4-organ reflex controller whose decision layer is matrix multiplication through connectome weights, plus MAVLink v2 & ROS 2 bridges. 24,024 B C99 state, 107.5 KB WASM. Closed-loop boat sim: 66.7% safe arrival vs 4.6% with shuffled wiring and 0% for a classical stack — and 80.0% with the analytic model. |
necklink-cns |
NLTP (v1.6.0) |
Cervical connective (name only) | Loss-healing GF(2^8) Cauchy FEC file & priority-command transport with X25519 + PSK forward-secret ChaCha20-Poly1305, zero-dependency LZ4, and a 4.76 KB MCU profile over UDP or ESP-NOW, in Python, C99, JS/TS, Java and Arduino (248/248 cross-language checks; hardware-tested on ESP32/ESP8266). Unchanged in this release. |
pynltp |
NeckSight (v3.0.0) |
Optic lobe (64 LPLC2, 32 LC4) |
Collision and thin-obstacle looming reflex with 3-DOF gyro derotation; receptive fields compiled from the connectome. Wiring helps on thin poles/wires but misses the strict shuffle threshold; the analytic model and gyro-derotated Farneback do better overall. | necksight |
NeckCompass (v3.0.0) |
Central complex (EPG, PEN, Delta7, PFL3, PFL2) |
9-axis ring-attractor heading and GPS-denied homing on connectome matrices. Shuffled wiring breaks it (homing 100% → 4.7%), but the real wiring drifts and is far less accurate than the analytic model or an EKF. |
neckcompass |
NeckCord (v3.0.0) |
VNC leg-to-leg inhibition (6×6), DN → leg pools |
Six-leg gait whose tripod pattern emerges from the connectome inhibition matrix (0.855 vs 0.411 shuffled), plus engineering allocator, ESC observer and 18-servo IK. |
neckcord |
NeckSense (v3.0.0) |
Mushroom body (1,024 Kenyon cells, real claws) |
Integer novelty detection and continual memory. Shuffled wiring performs the same as real wiring, and classical baselines win on real UCI gas data. | necksense |
v3.0.0: what the connectome does, and what we measured
What comes from the connectome
necklink_cns.connectome.extract pulls circuits out of BANC v888 and compiles them into small weight tables (shipped as data/*.npz and C headers *_banc_weights.h):
| Organ | Circuit taken from BANC v888 |
Numbers kept | Hand-designed around it |
|---|---|---|---|
| NeckCompass | 50 EPG, 42 PEN, 40 Delta7, 25 PFL3, 12 PFL2 → 16 wedges |
~3,900 |
Rate dynamics, gains, wedge mapping, magnetometer gate |
| NeckSight | 64 of 181 LPLC2, 32 of 114 LC4 receptive fields (retinotopy inferred from connectivity) |
~18,700 |
Retina, T4/T5 motion detectors, thresholds |
| NeckSense | 1,024 of 4,122 Kenyon cells with real projection-neuron claws, APL, MBON |
~10,000 |
Sensor → glomerulus mapping (arbitrary), learning rules |
| NeckCord | 6×6 VNC leg-to-leg inhibition, 6×10 DN → leg pools |
96 |
Oscillator dynamics, IK, allocator |
| NeckLink CNS | 11 brain populations → 10 DNs (10×11) |
110 |
Sensor → population drive, DNa02 response curve, MDN inhibition |
So roughly 33,000 numbers from 23.5 million synapses drive the computation; everything else is engineering. Non-biological layers (allocator, ESC observer, IK, retina, vibration front-end, MAVLink, ROS 2) are labelled PROVENANCE = "engineering" in code.
How it was tested
- Shuffled-wiring control:
K = 100Maslov–Sneppen degree-preserving rewirings of the raw neuron-to-neuron matrices (every neuron keeps its in-degree, out-degree and synapse-weight multiset; verified for all39matrices), compiled by the identical pipeline with no per-shuffle tuning. - Statistic: one-sided permutation
p = (1 + r) / (K + 1),r= shuffles at least as good as the real wiring. Pre-registered pass:p ≤ 0.01andz ≥ 2(which requiresr = 0). - Baselines: the v2 analytic model and classical methods (χ²-gated EKF, Madgwick, gyro-derotated Farneback/Lucas–Kanade, One-Class SVM, Isolation Forest, nearest centroid, SciPy bounded QP, …) with identical inputs and preprocessing. Real public data (UCI gas drift, CWRU bearings) uses strict chronological / cross-load splits.
- Scale:
N = 30seeds, 3D MuJoCo (EGL) where relevant, run on Google Colab (NVIDIA RTX PRO 6000 Blackwell, 48 vCPUs). An independent audit checked the code for rigging, leakage and shuffle validity before release. Code, raw JSON and reproduction steps:benchmarks/v3/.
Results
| Organ | Task | Real wiring | Shuffled (mean) | r / 100 |
p |
Verdict | Best method |
|---|---|---|---|---|---|---|---|
| NeckCompass | Heading under waves + 125° magnetic spikes (RMS) |
12.84° |
62.82° |
0 |
0.0099 |
pass | EKF 0.81°, analytic 0.99° |
| NeckCompass | Heading after 10 s of darkness (RMS) | 73.6° |
85.6° |
31 |
0.32 |
fail | Gyro integration 0.53° |
| NeckCompass | Closed-loop homing (arrival) | 100% |
4.7% |
0 |
0.0099 |
pass | Analytic: 100%, closer |
| NeckCord | Emergent tripod gait (order) | 0.855 |
0.411 |
0 |
0.0099 |
pass | Analytic table 1.000 |
| NeckCord | Turning in MuJoCo (yaw in 5 s) | +4.13 rad |
+2.05 rad |
1 |
0.020 |
marginal | — |
| NeckCord | Walking after leg loss (MuJoCo) | 0.84 m |
0.79 m |
15 |
0.16 |
fail | Analytic 0.87 m |
| NeckLink CNS | Closed-loop boat mission (safe arrival) | 58.3% (66.7% over 30 seeds) |
4.6% |
2 |
0.030 |
marginal | Analytic 80.0% |
| NeckSight | Collision detection, all obstacles (AUROC) | 0.806 |
0.763 |
7 |
0.079 |
fail | Analytic 0.890 |
| NeckSight | Thin poles and wires (AUROC) | 0.755 |
0.672 |
3 |
0.040 |
marginal | Analytic 0.987 |
| NeckSense | UCI gas novelty (AUROC) | 0.666 |
0.672 |
74 |
0.74 |
fail | One-Class SVM 0.698 |
| NeckSense | UCI gas 5-shot continual (accuracy) | 42.7% |
43.2% |
65 |
0.65 |
fail | Nearest centroid 60.1% |
| NeckSense | CWRU bearing faults (AUROC) | 0.9995 |
0.99998 |
100 |
1.00 |
fail (ceiling) | Several at 1.000 |
Plain summary:
- Wiring structure matters where the circuit's job is geometry — the compass ring, homing, gait coordination and the whole controller. Scrambling it (same degrees, same weights) breaks those behaviours.
- It does not matter in the mushroom body: any sparse random projection with the same degree distribution does as well (consistent with Dasgupta et al., Science 2017).
- The real wiring is never the most accurate option. The hand-tuned symmetric model or a classical method wins every head-to-head. Real circuits carry left/right asymmetries (for example, the compass bump drifts up to
~10°/swith no input).
Caveats you should weigh:
- The pipeline was developed while looking at real-wiring results, so the shuffle comparison is biased toward the real wiring.
- No correction for testing many things at once; with
K = 100no result can clear a corrected threshold. The large effects (homing, tripod, whole controller) are robust;p = 0.02–0.04results are not convincing. - Some shuffle comparisons use
6–12seeds per shuffle; the NeckSight test has56rendered episodes. - Everything except the UCI gas and CWRU data is simulation. Nothing has run on real hardware; microcontroller speed has not been measured (desktop C99:
~166 µsper full controller tick).
Earlier corrections (v2.0.1, 14 November 2026): withdrawn v2.0.0 claims
An independent audit of the v2.0.0 benchmark suite found:
- Not measured: the "250-episode survival gauntlet" (
100%vs77.2%vs1.2%vs0%) never ran NeckLink code — every controller was hand-scripted. The hexapod leg-loss result (2.07×) came from a leg posture hard-coded in the benchmark. - Unfair or leaky: NeckSight
0.984AUROC /85.7%thin-pole recall (baselines denied gyro correction; negatives were 3 sequences copied 14×); CWRU bearing1.000AUROC (normal data scaled 4.5×, baselines denied normalisation); continual gas93.4%(test set contained training rows); compass2.48 supset recovery (equals a parameter the benchmark set). - Mislabelled: the
BANC v888"specificity" test used random node sets, not a degree-preserving null. In v2 the libraries used the connectome only for names and a few constants.
v3.0.0 replaces those benchmarks with the suite described above.
Release notes
v3.0.0 (November 2026) —
necklink,necklink-cns,necksight,neckcompass,neckcord,necksense:
- Connectome-derived weights by default in all five packages (
connectome_weights="banc_v888"), in Python and zero-float C99, with the earlier models kept asconnectome_weights="v2_analytic".- New
necklink_cns.connectomeextraction + Maslov–Sneppen shuffling tools (pip install "necklink-cns[connectome]").- New audited benchmark suite with shuffled-wiring controls (
benchmarks/v3/).- Fixes from the independent audit: the C99/WASM controller now uses the connectome compass weights; WASM singletons excluded from MCU builds (
0 B.bss); importingnecklink_cnsno longer needs SciPy/pandas; engineering classes carryPROVENANCElabels.- All five Arduino libraries compiled for
esp32devwith the ESP32 (Xtensa) toolchain.NLTP(pynltp1.6.0) is unchanged.
Install
pip install --upgrade necklink
# or install individual modules:
pip install --upgrade necklink-cns pynltp neckcompass necksight neckcord necksense
# connectome extraction + shuffling tools (needs the raw BANC v888 dataset):
pip install --upgrade "necklink-cns[connectome]"
Every package supports Python 3.9+ and depends only on NumPy at runtime (pynltp also uses cryptography). Each package's C99 core (csrc/) and Arduino library (arduino/) are self-contained with zero external C dependencies.
Run the unified controller & encrypted NLTP reflex mission
necklink-cns demo # 4-organ reflex controller + MAVLink v2 demo
necklink-cns priors # BANC v888 connectome summary statistics
necklink products # List all installed NeckLink packages and versions
necklink suite-demo --loss 0.15 # Closed-loop reflex mission over encrypted, lossy NLTP UDP
import numpy as np
from necklink_cns import NeckLinkCNS
cns = NeckLinkCNS(vehicle="hexacopter", grid_size=32) # connectome_weights="banc_v888" by default
out = cns.step(
dt=0.02,
speed_m_s=1.8,
gyro_xyz=np.array([0.02, -0.01, 0.05]),
accel_xyz=np.array([0.2, -0.1, 9.80]),
mag_xyz=np.array([0.45, 0.05, 0.89]),
camera_frame=np.full((32, 32), 160.0),
)
print(out.descending.behavior_mode, len(out.cervical_wire_4b), hex(out.mavlink_manual_pkt[0]))
Repository layout
necklink/
├── packages/
│ ├── necklink_cns/ 4-organ controller, connectome extraction/shuffling, MAVLink v2, ROS 2, WASM (v3.0.0)
│ ├── nltp/ NLTP wire protocol (v1.6.0): Python, C99, JS/TS (Node.js), Java 11+, Arduino, ESP32/ESP8266
│ ├── neckcompass/ Ring-attractor compass, plastic ring & homing on connectome matrices (v3.0.0)
│ ├── necksight/ LPLC2 + LC4 looming on connectome receptive fields, 3-DOF derotation (v3.0.0)
│ ├── neckcord/ Connectome gait coupling, allocator, ESC observer, 18-servo IK, 4-byte codec (v3.0.0)
│ └── necksense/ Connectome Kenyon-cell projection, novelty & continual memory (v3.0.0)
├── benchmarks/v3/ Audited v3.0.0 benchmark suite, raw subgraphs and results JSON
├── umbrella/ The `necklink` PyPI meta-package (v3.0.0) that installs all six packages
├── web/ Live C99 WebAssembly + webcam website (deployed to gh-pages)
└── assets/ NeckLink logo, brand banner and figures
Every folder under packages/ is a self-contained project with its own pyproject.toml, tests, zero-float ANSI C99 core, Arduino library, README and MIT licence, and is released independently to PyPI (import necklink_cns, import nltp, import neckcompass, import necksight, import neckcord, import necksense).
Development
Work inside the package you are changing:
cd packages/necklink_cns
pip install -e . pytest
python -m pytest # unit tests, MAVLink v2, Arduino parity
make -C csrc clean all test sanitize # zero-heap/zero-float C99 controller (< 24 KB) + ASan/UBSan
CI (.github/workflows/packages-ci.yml) runs on Python 3.9 and 3.13 across NeckLink CNS, NeckCompass, NeckCord, NeckSense, NeckSight, and NLTP (including -Werror + ASan/UBSan C99 checks, Arduino SHA-256 mirror parity, Node.js 20, Java 21, and 248/248 4-language wire interop):
- builds each package's wheel and installs it outside the source tree;
- runs its CLI smoke checks;
- executes all unit tests and every README Python example;
- compiles its zero-heap ANSI C99 core with
-std=c99 -Wall -Wextra -pedantic -Werrorand runs its self-tests.
History
NeckCompass, NeckSight, NeckCord and NeckSense started in their own repositories and were merged here with their full commit history on 4 November 2026. The old repositories are archived and read-only.
License
Released under the MIT License. Copyright (c) 2026 Amandeep Singh Bains.
The BANC v888 connectome data used to compile the weight tables comes from the Brain-and-Nerve-Cord project (Bates et al., 2025); please cite it if you use the connectome-derived weights.
Metadata
Release files for necklink 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| necklink-3.0.0.tar.gz | 12.1 kB | Without provenance | Details for necklink-3.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| necklink-3.0.0-py3-none-any.whl | Python 3 | none | any | Details for necklink-3.0.0-py3-none-any.whl |
Total release size: 22.1 kB
Release files / necklink-3.0.0.tar.gz
| Download URL | necklink-3.0.0.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
85d0df3f474f3d6920d8e498516041eff846324e45995e7569d4b6ed407767a6
|
|
BLAKE2b-256 checksum How to use checksums |
624e674e68a160aba351b67352610e84a941b1786c69916459aaddd1a601158a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / necklink-3.0.0-py3-none-any.whl
| Download URL | necklink-3.0.0-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
73d140a39acd8dac60e4684d9b8f3462f0d510d8f769eda36864d1c9b3e84310
|
|
BLAKE2b-256 checksum How to use checksums |
3d4eb30283004ebf2a1e7db050ae8152f1d2d1e84010c27aa84848475616aaba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for necklink 3.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.