Tap what leaks in your house, and Shutoff names the valve or breaker that cuts it, which feeds it cuts, which still run, and what else goes off.
Try it: https://midknight56.github.io/shutoff/ (no sign in, no key; once the page shows "Available offline", it works with no network)
You see water on the floor. You do not know which valve under which sink, or which breaker in which panel, turns it off. Shutoff knows, because the house is written down as what feeds what. A tap or a shower has two feeds, cold and hot, from two different valves. Shutoff asks which one leaks. It shows the valve, the feeds it cuts, the feeds that still run, where the valve is, and the list of everything that loses supply when you close it. It also answers the slow questions: what to switch off before two weeks away, what a breaker carries, and where the record has gaps.
Safety: Shutoff only says close or switch off. For gas it says to close the valve only if you can do so safely, leave the house, and call the gas company or a licensed gas fitter from outside. For wiring it says to call a licensed electrician. The Away list leaves gas as it is. The emergency screen says which house it is (the demo or yours). It checks every cold and hot feed against the main it names, and lists each feed that comes from another main, reaches no main, or is not in the record, because closing that main may not stop it.
- Mode: directory. The house is a folder of notes, written by Relate's markdown codec, one note per thing (
store/house/). - Why this mode: the notes folder is the house binder. A person can read and edit
store/house/Valve/water-main.mdon GitHub or in a notes app, and Relate reads the edit at the next open (a test changes a valve's spot in its note and opens the store again). The build writes the demo notes fromshutoff/house.py, so a rebuild replaces a hand edit to a demo note. - What the graph models: rooms, fixtures, valves, breakers, panels, pictures and service notes, linked by what feeds what (the tables below).
python -m shutoff build also writes two copies of the same graph. store/house.rl is one file, for the relate CLI and its MCP server. web/public/seed.cypher is a script, for the page, because the browser build cannot open a folder or a file; the page runs it in Relate's WebAssembly build. A Python test loads the notes folder, the .rl file and the seed script and compares the counts, the links, the node properties (all but the codec's own type, labels and body fields) and the 7 gaps. A page test compares the node counts in the browser with the CLI. Your own house, added in the page, lives in an opfs:// store in your browser and stays after a reload.
| Node | Holds |
|---|---|
Room |
name, floor |
Fixture |
name, kind, critical (a freezer or sump pump must not lose power), heater (it heats water), needs (the feeds it should have) |
Valve |
name, supply (water, hot or gas), main, spot (exactly where it is) |
Breaker |
name, amps, main, slot, spot |
Panel |
name |
Picture |
name, file (a drawn card, or your own photo) |
Service |
name, date, what, who |
| Link | Means |
|---|---|
WATER_FROM |
fed with cold water by that valve |
HOT_FROM |
fed with hot water by that valve (a hot valve is fed by the water heater) |
POWER_FROM |
fed with power by that breaker |
GAS_FROM |
fed with gas by that valve |
IN |
in a room |
IN_PANEL |
a breaker in a panel |
SHOWS |
a picture shows a control |
ON |
a service note is about a thing |
The water heater is a fixture and a source. It is fed by cold water and by its breaker, and it feeds the hot valves. A fixture's needs list keeps the feeds it should have, so a lost link shows in Gaps even when another feed stays. Each supply has its own link type, so no query needs a filter inside a path. Every walk has an upper bound of 12 links or less, and collects its set before it filters. Because lookups stop at 12 links, a save or restore that would make a chain of 12 or more is refused, and a route that reaches 12 is shown as incomplete. A breaker's panel is read from its IN_PANEL link. A lint test checks all query files for these rules.
You need Python 3.10 or newer (tested on 3.10 and 3.12) and Git. The relate CLI is only for one step below. The page needs Node 20 or newer.
PowerShell (Windows):
git clone https://github.com/Midknight56/shutoff
cd shutoff
python -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt --quietBash (macOS, Linux):
git clone https://github.com/Midknight56/shutoff
cd shutoff
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt --quietThe commands below are the same in both shells, with the virtual environment active.
Check the house and list the gaps in its record:
python -m shutoff check17 rooms, 65 fixtures, 16 valves, 28 breakers, 2 panels
gap: garden-tap no way back to a main
gap: spare-breaker feeds nothing
gap: bedroom-three-circuit has no picture
gap: dryer-gas-cock has no picture
gap: kids-bath-toilet-stop has no picture
gap: basement-circuit carries a critical thing beside ordinary ones
gap: attic-fan has no feed in the record
7 gaps
The shower upstairs leaks, and you cannot tell if it is hot or cold:
python -m shutoff stop main-bath-showerleak at main-bath-shower, not sure if hot or cold. It has 2 feeds: cold water from upstairs-cold-branch, hot water from hot-main-out
close water-main in the utility room: it cuts cold water and hot water
where: where the pipe comes through the front wall, left of the heater, blue wheel handle
picture: pictures/water-main.svg
goes off with it (15): dishwasher, fridge-ice-maker, half-bath-sink, half-bath-toilet, kids-bath-sink, kids-bath-toilet, kids-bath-tub, kitchen-tap, main-bath-shower, main-bath-sink, main-bath-toilet, outdoor-tap, utility-sink, washer, water-heater
or close both nearest valves: upstairs-cold-branch and hot-main-out
It is the hot side:
python -m shutoff stop main-bath-shower --supply hotleak at main-bath-shower, the hot side. It has 2 feeds: cold water from upstairs-cold-branch, hot water from hot-main-out
close hot-main-out in the utility room: it cuts hot water
still on: cold water from upstairs-cold-branch
where: on the hot pipe on top of the water heater, red wheel handle
picture: pictures/hot-main-out.svg
goes off with it (9): dishwasher, half-bath-sink (hot only, cold stays), kids-bath-sink (hot only, cold stays), kids-bath-tub (hot only, cold stays), kitchen-tap (hot only, cold stays), main-bath-shower (hot only, cold stays), main-bath-sink (hot only, cold stays), utility-sink (hot only, cold stays), washer (hot only, cold stays)
the main, water-main, would turn off 15 things
Everything the shower depends on, across water and power, with the route Relate returns:
python -m shutoff depends main-bath-shower1 step: hot-main-out (valve), direct
1 step: upstairs-cold-branch (valve), direct
2 steps: water-main (valve, main) via upstairs-cold-branch
3 steps: heater-breaker (breaker) via hot-main-out > water-heater
3 steps: heater-cold-in (valve) via hot-main-out > water-heater
4 steps: main-breaker (breaker, main) via hot-main-out > water-heater > heater-breaker
What if the heater's cold inlet were closed? This runs on a copy in memory, in a transaction that rolls back:
python -m shutoff whatif close heater-cold-inif heater-cold-in were closed, 10 supplies are cut:
dishwasher loses hot water
half-bath-sink loses hot water
kids-bath-sink loses hot water
kids-bath-tub loses hot water
kitchen-tap loses hot water
main-bath-shower loses hot water
main-bath-sink loses hot water
utility-sink loses hot water
washer loses hot water
water-heater loses cold water
rolled back: the house is unchanged
The heater breaker cuts power to the heater only. The hot taps still get water:
python -m shutoff off heater-breaker1 thing loses supply: water-heater
Away for two weeks:
python -m shutoff awayclose: water-main
switch off: bedroom-three-circuit, bedroom-two-circuit, dining-room-circuit, dishwasher-circuit, dryer-circuit, entry-lights, garage-subpanel-feed, half-bath-circuit, heater-breaker, kids-bath-circuit, kitchen-counter-1, kitchen-counter-2, living-room-circuit, main-bath-circuit, microwave-circuit, primary-bedroom-circuit, range-circuit, washer-circuit
keep on: basement-circuit, freezer-circuit, fridge-circuit, furnace-circuit, smoke-alarms
gas: leave it as it is.
The same query files run in the relate CLI (install it). In Bash:
relate query -d store/house.rl --read-only --mode table --param control=kitchen-cold-stop < queries/04-goes-off.cypher+--------------------+-------------+----------+--------------+
| name | kind | critical | feed |
+--------------------+-------------+----------+--------------+
| "fridge-ice-maker" | "appliance" | false | "WATER_FROM" |
| "kitchen-tap" | "tap" | false | "WATER_FROM" |
+--------------------+-------------+----------+--------------+
In PowerShell, which has no <:
Get-Content -Raw queries\04-goes-off.cypher | relate query -d store\house.rl --read-only --mode table --param control=kitchen-cold-stopAll commands: python -m shutoff check | stop <fixture> [--supply water|cold|hot|power|gas] | off <control> | depends <fixture> | away | whatif close <control> | import <house.cypher> --to <folder> | build.
You need Node 20 or newer.
cd web
npm ci
npm run build
npm run serveThen open http://127.0.0.1:5174/. Tap a fixture, then Cold, Hot or Not sure. The picture cards of the demo house are drawings, and each says "Illustration". Tap "What feeds this?" for every valve and breaker it depends on within 12 links, with each route drawn. Tap a diamond (a valve) or a panel. Open "My house" to add your own rooms, valves, breakers and fixtures. Valves and breakers take a photo and an exact spot. "Save as house.cypher" gives a file with the photos inside. "Open a saved house" loads it back. python -m shutoff import house.cypher --to store/mine turns it into notes, a .rl file and a folder of photos.
Relate's own MCP server opens the house read only, with no code of ours:
{"mcpServers": {"shutoff-house": {"command": "relate", "args": ["serve", "--mcp", "stdio", "--database", "store/house.rl", "--read-only"]}}}docs/AGENT.md lists 5 questions an agent can ask. It quotes each query file word for word, and a test checks the quotes against the files. Another test starts this server and asks it what goes off with the kitchen stop, with the same query file (tests/test_mcp.py).
tools/guard.py runs a command under a memory cap and a time limit, and stops the command and all its children when it passes either. On Windows it uses a job object. On Linux and macOS it watches the memory of the whole process group. The Python test run goes through it, and the page tests call the CLI through it. In the page, Relate runs in a web worker. Each call to the engine gets 2 seconds (one tap can make several calls), a photo write 5 seconds and opening a saved house 10 seconds; past that the page ends the worker and starts a new one.
PowerShell (Windows):
python -m pip install -r requirements-dev.txt
python -I tools/guard.py --mem-mb 1500 --secs 240 -- .venv\Scripts\python.exe -m pytest -q
cd web
npm ci
npx playwright install chromium
npm run build
npx playwright testBash (macOS, Linux):
python -m pip install -r requirements-dev.txt
python -I tools/guard.py --mem-mb 1500 --secs 240 -- .venv/bin/python -m pytest -q
cd web
npm ci
npx playwright install chromium
npm run build
npx playwright test| Path | What |
|---|---|
store/house/ |
The demo house as notes (Relate markdown codec), one note per thing. Written by the build from shutoff/house.py. |
store/house.rl |
The same house as one file, for the relate CLI and the MCP server |
store/house-fixed/, store/house-fixed.rl |
The same house with every gap repaired: 0 gaps |
web/public/seed.cypher |
The same house as a script, for the page |
queries/ |
The questions, one statement per file. The CLI, the tests, the page and the agent guide use these files. The builder and the export write their own CREATE lines, and the store snapshot in shutoff/store.py reads with two short statements of its own. |
pictures/ |
Drawn picture cards of the demo valves and breakers, each marked "Illustration" |
opfs://house |
Your own house, in this browser's storage. The page has no server code, and a page test records every request while an owner builds a house: all go to the page's own address. |
python -m shutoff build makes the stores, the seed and the cards from shutoff/house.py. The demo house is invented: no real address, person or home (docs/DATA.md). The room outlines of the demo drawing are in web/src/layout.js; fixtures and valves are placed from query rows.
Relate and connected context. A house is four supply graphs in one: cold water, hot water, power and gas. Each feed is its own link type. "What stops this leak" is a walk up from the fixture, one feed at a time (queries/01-stop-leak.cypher). "What goes off" is a walk down that names the feed each fixture loses (queries/04-goes-off.cypher). The upstairs shower depends on 6 controls across two supplies. The farthest is the main breaker, 4 steps away: shower, hot main out, water heater, heater breaker, main breaker. The page draws that route from the path Relate returns. The house is a folder of notes in directory mode (store/house/). The build also writes it as one .rl file (store/house.rl) and as a script that Relate's WebAssembly build loads in the page, which keeps your own house in the browser's opfs:// store.
Functionality and completeness. The demo house holds 173 things and 303 links. The CLI, the page and the agent guide ask their questions through 37 query files. The CLI has 8 commands. The page answers stop, what goes off, what feeds this, away and gaps, and edits your own house, with no server. What if runs in the CLI only. Every save checks its feed in the same query. It refuses a loop found within 12 links, a feed of the wrong supply, a hot feed from anything but a hot valve or a water heater, and clearing the heater mark while hot valves hang off it; on a refusal nothing changes. Before a save, the page also counts the links up and down, and refuses a chain of 12 links or more, because lookups stop at 12. Opening a saved house writes it into a second browser store and checks it there for errors, loops, things with no name and chains of 12 links. The page switches to that store only when the whole write and check succeed. A test stops a restore half way, and another opens a broken file: both times the old house, photos, links and leak answer stay. The saved file keeps each fixture's expected feeds, so a feed lost after a restore still shows in Gaps. 102 Python tests and 20 browser tests pass. The commit messages record the failing runs before each fix.
Usefulness. A leak at the shower asks: cold, hot or not sure. Not sure leads with a valve that cuts both feeds. If there is none, it leads with the nearest valve of each feed together, each with its spot and photo. If the record is missing a feed the fixture should have, it says "Cannot confirm a full shutoff" and names that feed. Each answer says which feeds the valve cuts and which still run, the spot when one is recorded, and what else goes off. Ties go to the valve that turns off fewer things. Owners add their own valves and breakers with a photo and an exact spot, and fixtures with their feeds, and change or remove them. A feed can be marked "not sure yet": it shows in Gaps, and no full shutoff is claimed until it is filled in. Adding a room again with the same name changes its floor; rooms cannot be renamed or removed. A short first setup walks through a room, the main valve with spot and photo, one fixture and a practice lookup that counts once an answer shows. The Gaps tab lists 7 holes in the demo record.
Documentation and reproducibility. Every command in "Setup and run" that is marked Bash and shows output has its real output pasted under it. A test copies the tracked files to a new folder, runs those commands and compares the output line by line (tests/test_readme.py). It skips the relate command when that tool is not installed. Setup has separate PowerShell and Bash steps.
Creativity. A house binder that is also a graph: it answers in the basement with no network once cached, reads like notes on GitHub, and goes with the house as one file.
| Part | When |
|---|---|
| All code, data, queries, pictures and tests in this repo | Written during the contest, first commit 3 Dec 2026 |
Relate (relate-db 1.5.0, @relate/relate-wasm 1.5.0) |
Open source, by Neo4j |
| pytest, Playwright | Open source test tools |
MIT. See LICENSE.
