Formicarium/BIBLE
Appearance
Formicarium — Project Bible
Single source of truth for what Formicarium IS, is NOT, and the rules that keep it coherent. README says how to build and run it; this says how to think about it. The finish line lives in
docs/RELEASE.md.
1. The one sentence
Formicarium is a self-regulating ant habitat for one Tetramorium immigrans colony: a rigid acrylic column with a heated, passively hydrated Ytong nest, ESP32 firmware in C# on .NET nanoFramework, and a local Blazor dashboard that runs the same control core against a colony simulator.
2. The product promise
- The colony stays warm (nest 79–83 °F), humid, ventilated and fed with sugar water without daily care.
- Every failure worth worrying about is slow, and the safety rules are proven by tests, not hoped about.
- One hardware-free control core runs unchanged in the firmware, the desktop tests and the dashboard simulator.
- The column can be built from the dashboard's Build page (3D blueprint, drawings, parts and pin tables, 44-step sequence) with no internet.
- A behavioural experiment rides along: each riser mouth is lit in a colour tracking its own traffic, rotated at local midnight.
3. What it is NOT
- NOT gated: there is no powered gate between nest and outworld (no firmware can tell closed from stuck).
- NOT a pumped nest: no pump ever reaches the nest; it fills a 131 mL reservoir that wicks into the core.
- NOT automated protein feeding: fruit flies stay manual.
- NOT a hosted web app: the dashboard runs locally (Azure is decommissioned; public hosting is out of scope).
- NOT a cooling or diapause system: the species needs neither.
4. Architecture canon
firmware/Formicarium.Controller/Core/ Actuation, Config, Control, Sensing, State (nanoFramework BCL only) |-- Formicarium.Controller.nfproj direct Compile Include -> .pe image for the ESP32 (build-firmware.ps1) |-- Formicarium.Controller.Tests linked sources, NUnit -> proves the control logic on the desktop `-- Formicarium.Dashboard linked sources -> simulator drives the real ControlLoop firmware/.../Hardware/ Esp32SensorSet, Esp32ActuatorSet (the only code that knows a GPIO) firmware/.../Net/ HttpApiServer (/api/state, feed, lighting, service mode), FallbackPage dashboard/ Blazor Server .NET 10, EF Core on SQL Server, settings in MindAttic Vault
4.1 Projects
firmware/Formicarium.Controller— nanoFramework app; not in the solution, built byfirmware/build-firmware.ps1with real MSBuild and the extracted nanoFramework VSIX (nothing installed machine-wide).firmware/Formicarium.Controller.Tests— NUnit over the linkedCore/sources.dashboard/Formicarium.Dashboard— pages Home, History, Traffic, Camera, Build;ColonyMonitoris the single poller of the controller;TelemetryStoreandBuildProgressStorepersist to SQL Server.dashboard/Formicarium.Dashboard.Tests— NUnit for the Vault settings import.run.ps1/run.bat— the shared run menu deploying the dashboard toR:\MindAttic\Apps\Formicarium.
4.2 Domain model
- Column — base, nest, electronics bay (with drawer), outworld, lid; three load-bearing risers.
- Riser — one of three ant paths, each with an IR break-beam and an RGB ring under its mouth.
- Reading / SensorSnapshot — one sensor value, invalid on failure, never stale.
- Setpoints — every threshold and timer (
Core/Config/Setpoints.cs). - DeviceState — the published state the dashboard polls; carries fault bits.
- Faults — bit flags shared by firmware and dashboard; must match by name and value.
4.3 Key services
ControlLoop— one tick: read sensors, run the controllers, apply the watchdog, actuate.HysteresisController(heater, fans),HydrationController(float-switch refill),FeedScheduler(daily sugar dose),LightingController(channel rotation, curfew 22:00–07:00),SafetyWatchdog(cross-sensor over-temperature cutout).ColonySimulator/FakeFormicariumClient— thermal, hydration and foraging model at 120x wall-clock.
5. The Laws
Inherits MindAttic.HouseRules.md by reference.
- A failed sensor read is an invalid
Reading, never a stale value. - Fail-safe is off, not hold, and bypasses dwell timers.
- The over-temperature cutout reads every nest probe, not just the control probe.
- Hydration keys off the reservoir float switch; nothing pumps into the nest.
- Boot state is every output off; nothing energises until a sensor has read successfully.
- No scheduled feed runs until the clock is set (SNTP); a reboot never doses twice.
-
Core/uses only the nanoFramework base class library (no LINQ, no generic collections). -
docs/gpio-map.md,Core/Config/PinMap.csand the Build page pin table always agree. - Wi-Fi credentials never enter git; they live in the device config block (
nanoff --updatessid). - Every logged traffic row carries the channel and brightness in force when it was counted.
6. Verified state
- Firmware compiles to a deployable
.peimage plus dependencies (firmware/build-firmware.ps1). - Control core tested on the desktop (NUnit, converted from xUnit in FOR-T14).
- Dashboard runs the real
ControlLoopagainst the simulator; settings in Vault (FOR-T23). - Not yet verified: the firmware has never run on an ESP32; nothing has been ordered or built; the R: deploy and a local SQL default are open tasks (see
docs/RELEASE.md).
7. Active frontier
See docs/RELEASE.md: milestone "first column built and ready for a colony" and its epics. Design record: formicarium-project.md; parts and cut list: docs/bom.md; pins: docs/gpio-map.md.
8. Quality bar
- The solution builds clean; firmware changes also build with
firmware/build-firmware.ps1. - Any control-logic change keeps the Laws above and is covered by a test in
Formicarium.Controller.Tests. - Pin changes update all three places in FOR-LAW-8 in the same commit.
- Docs describe current truth: README, design record and BOM change when the hardware does.
9. Glossary
- Ytong / AAC — autoclaved aerated concrete; the carved, wicking nest medium.
- Outworld — the foraging arena above the bay, with the feed dish.
- Riser — a ¾ in acrylic tube carrying ants and load between nest and outworld.
- Fluon — PTFE coating below the lid rim; the escape barrier.
- ClosedLoop / Fixed / Off — lighting modes: treatment, lit without information, dark baseline.
- Service mode — dashboard switch that forces the actuators off and refuses manual feeds while the column is serviced.
- nanoFramework — .NET runtime for microcontrollers;
nanoffis its flashing tool.
Part of Formicarium.
From Formicarium/docs/BIBLE.md via MindAttic.Docs; synced automatically, so edit the repo, not this page.