# FlyGateDemo The olfactory circuit of a fruit fly, taken from the MaleCNS connectome, guards the gate of a real blog. Requests become odors, a single dopamine-gated punishment teaches the fly to avoid scanner probes, and rewards teach it to let readers in. Everything runs in C# on .NET 10, without Python. The honest result first: on this traffic the fly is not a better gatekeeper than plain cosine similarity. The interesting part is what the real wiring does with one example and a tiny, fixed memory. ## Quick start ``` dotnet run -c Release --project FlyGateDemo -- run ``` The repository contains both inputs, so nothing has to be downloaded. A run takes about 20 seconds. Add `--wiring` for the control with shuffled and random wiring (about 2 minutes). ## What the run shows All numbers come from the bundled sample: 142,770 requests to [roberttroska.pl](https://www.roberttroska.pl) between 8 February and 25 September 2026, most of them probes for WordPress, `.env` files and uploaded PHP shells. | Experiment | Result | |---|---| | Novelty (α'3 compartment) | Half of its synapses are depressed after about 15 different odors. With one-hour recovery the fly raises 17.4 alarms a day, only 1.36 times better than chance. | | One punishment per probe family | The fly avoids 23–88% of later probes of that family and blocks 0.1–8% of readers. | | Baselines at the same reader false alarms | Exact match: 0–32%. Cosine on the 53 receptor channels: 62–98%. Cosine on the text: 98.5–100%. | | Six punishments | 94–100% of probes, but also 67.2% of readers (Googlebot 91.0%, Bingbot 82.5%, GPTBot 62.9%). | | Six punishments, then three rewards | Readers drop to 1.3% while 43–82% of probes are still avoided. | | Wiring control | Real PN→KC wiring blocks 59% of a family and 1.9% of readers, shuffled 54–59% and 2.1–4.0%, random 64–68% and 5.5–8.3%. | A reader is anyone who opens blog pages, including search engine robots. Smelling one request takes about 85 µs on one core of an Intel Core Ultra 5 225H. ## How the model works - **Nose.** The only invented part. Each of the 53 receptor types (as many as the ORN types in the map) responds more or less strongly to every three-character fragment of the path and the User-Agent header. Receptors adapt to the background, so the omnipresent `Mozilla/5.0` stops dominating. - **Antennal lobe and mushroom body.** A rate model, not spikes. ORN types drive projection neurons with the real synapse counts, local neurons normalize the signal, and Kenyon cells sum their PN inputs. APL keeps the top 5% of Kenyon cells in each class (γ, α'β', αβ), so every request becomes a sparse code of 102 out of 2,044 cells. - **Learning.** A dopamine pulse depresses the KC→MBON synapses of the active cells to 10%: PPL101 on MBON11 for punishment, PAM01 on MBON01 for reward, PPL104 on the α'3 MBONs for novelty. The fly avoids a request when the MBON11 response falls below 80% and rewards do not balance it. ## Commands | Command | What it does | |---|---| | `run [sample.tsv.gz] [--wiring]` | Runs all experiments on the bundled sample or on another file in the same format. | | `anonymize [--skip-ip ]...` | Turns the blog's raw `visitors_*.log` files into a sample. This is how the bundled one was made. | | `build [circuit.bin]` | Builds the circuit file from the two MaleCNS Feather files in about 7 seconds. | | `stats [circuit.bin]` | Prints the neurons and synapses in a circuit file. | ## Data **`FlyGateDemo/Data/olfactory-circuit-right.bin`** (933 KB) holds 2,635 ORNs and 686 PNs from both sides, and 2,044 Kenyon cells, 49 MBONs and APL from the right side of [MaleCNS v1.0](https://male-cns.janelia.org) by FlyEM/HHMI Janelia, University of Cambridge, MRC LMB and Google Research, licensed [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). The `build` command recreates it byte for byte from `body-annotations-male-cns-v1.0-minconf-0.5.feather` and `connectome-weights-male-cns-v1.0-minconf-0.5.feather`. **`FlyGateDemo/Data/blog-requests.tsv.gz`** (1.6 MB) is a gzipped TSV with the columns `time`, `method`, `path`, `category`, `bot` and `user_agent`. Category and bot name come from the blog's own bot detector. The sample was anonymized as follows: - no IP addresses and no referrers, and the blog owner's own traffic is removed, - mailbox names in paths and User-Agent headers are masked (`[email]@anthropic.com`), - queries typed into the blog's search box are replaced with `[query]`. ## Limitations - The nose is invented, and it is the narrowest part of the pipeline. Cosine on its 53 channels already loses more than half of what separates the fly from cosine on the text. - The rate model avoids the runaway activity that a uniform spiking model shows in the antennal lobe and the mushroom body. It does not explain it. - The wiring control uses three seeds per variant, so it is a hint, not proof. ## Background The experiments are described in Polish on the blog: [Mucha na bramce bloga](https://www.roberttroska.pl/DevLog/Post/MuchaNaBramce), with an introduction to the connectome in [Mucha gra w Dooma?](https://www.roberttroska.pl/DevLog/Post/MapaMozguMuszki). The model draws on [Aso et al. 2014](https://elifesciences.org/articles/04580), [Hattori et al. 2017](https://www.cell.com/cell/fulltext/S0092-8674(17)30479-8), [Dasgupta et al. 2017](https://doi.org/10.1126/science.aam9868) and [Dasgupta et al. 2018](https://www.pnas.org/doi/10.1073/pnas.1814448115). Prepared by Robert Troska with support from Claude Opus 5.5 (research, code and measurements). ## License - Code: [MIT](LICENSE). - `FlyGateDemo/Data/blog-requests.tsv.gz`: © 2026 Robert Troska, [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). - `FlyGateDemo/Data/olfactory-circuit-right.bin`: derived from MaleCNS v1.0 by FlyEM/HHMI Janelia, University of Cambridge, MRC LMB and Google Research, [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).