Inspiration

On Piper Alpha in 1988, the inquiry's most likely explanation was that a condensate pump was restarted while its relief valve was out for maintenance under a separate permit, with a blind flange covering the opening. Many failures contributed, including permit organisation, isolation practice and shift handover. One of them is the subject of this project: the connection between the two jobs was not on either form. It was in the piping.

Every maintenance job on a process plant needs a permit to work, and its equipment must be isolated first. Two permits can each look fine alone and conflict together. That is a question about relationships, so I wanted to see how far a graph could take it.

What it does

Blind Flange checks a proposed permit or state change against a graph of the plant's piping, every open permit, and the recorded state of every valve and blind. It answers in two parts:

  • Assessment status: COMPLETE, INCOMPLETE or ERROR
  • Conflict verdict: BLOCK, HOLD or CLEAR

Every finding carries the path through the piping that proves it.

The headline case. A request to start pump A is blocked. Pressure would travel four hops from the pump to a temporary blind flange that another permit relies on. The two permits share no equipment tag, so matching permits by tag passes the request.

The obvious fix is not always enough. On a 151-component gas plant, closing the valve on the first path still returns BLOCK, because a bypass left open gives a second route 12 hops long.

It will not say CLEAR when it cannot know. If a valve on a possible route has no confirmed state, the result is INCOMPLETE, not CLEAR. The same happens for stale observations and for a search that reaches its hop limit.

It also catches a job that opens a valve another job relies on, an isolation that is listed but not in place, pressure reaching an open pipe end, and isolations or worksites shared by two jobs.

This is decision support. It checks for specified conflicts in the supplied plant and permit model. It is not a safety system and has not yet been reviewed by a process safety engineer.

What connects to what

  • (:Component)-[:CONNECTED_TO]-(:Component): the piping, made of equipment, lines, valves and blinds, each with a state and when it was observed
  • (:Permit)-[:WORKS_ON]->(:Component): where a job opens the pipework
  • (:Permit)-[:RELIES_ON]->(:Component): the isolation points protecting the job
  • (:Permit)-[:ENERGISES]->(:Component): equipment a job starts
  • (:Permit)-[:OPERATES {to}]->(:Component): a state change a job needs
  • (:Evaluation)-[...]->(:Snapshot): every assessment, including rejected ones, linked to a content-hashed record of its inputs

A conflict is a path from a live pressure source, through components that let pressure pass, to a place where another permit is working.

How I built it

Relate runs in single-file mode. One .rl file holds the plant, the valve and blind states, every permit and the audit trail, so one shift can hand the whole picture to the next as one file, with no server or network.

The graph finds the paths. exposures.cypher walks outward from every live pressure source with a quantified path pattern that filters on every hop, so the walk stops at each closed valve or installed blind and treats a removed component as an open end. SHORTEST 1 keeps one evidence path per conflict, and bound.cypher detects when a search was cut short.

The walk runs twice. A strict pass only crosses components whose state is known and current, so anything it finds is proven. A permissive pass may also cross unknown or stale states, so anything found only there is possible. A possible finding never blocks; it makes the result INCOMPLETE.

Each check is a dry run. The permit is written into the graph inside a transaction, the walk runs before and after its changes, and everything is rolled back. Comparing the two separates the hazards a request introduces from those that already existed:

$$ \text{introduced} = R_{\text{after}} \setminus R_{\text{before}} $$

Approval runs the same check, then commits the permit in a second transaction guarded by a store revision number, so an approval prepared against an older picture of the plant is refused. Every assessment is stored as an Evaluation node, and replay re-runs an old decision and detects a tampered record.

A small read-only MCP server lets an agent call the checks. It can read permit text and ask the tool, but the verdict always comes from the graph, and no tool can change plant state or permits.

Challenges

  • "No new path" is not "no problem". My first version only reported what a permit newly exposed. A hazard that already existed, or a second route to the same place, could hide behind that. The fix was to report existing and introduced hazards separately and never let one silence the other.
  • Not knowing is an answer. A missing valve state used to read as closed, which is the dangerous direction. Splitting the result into assessment status and verdict made "I cannot tell" a first-class outcome.
  • Trusting my own Cypher. I wrote an independent breadth-first search in plain Python and checked the Cypher against it on every eval case and on 120 random plants, plus mutation tests.
  • Honesty about the market. Commercial control-of-work products such as Sphera, Enablon and IntelliPERMIT already manage permits and isolations. Blind Flange does not replace them. It is a small, open, single-file tool whose every finding, and the inputs behind it, can be inspected and replayed.
  • Data. Real plant drawings are confidential, so both plants are illustrative models written for this project.

What I learned

  • Quantified path patterns with a per-hop filter express "walk until something stops you" exactly.
  • A rolled-back transaction is a clean way to ask a graph "what if" without touching the real state.
  • The most convincing output is a path, and the most trustworthy one is a refusal to answer when the data is not there.

Results

  • 35 eval cases. Each compares the graph check with plain tag matching and with the independent search. The search agrees on every case, and every replay reproduces its result.
  • Tag matching stops 8 of the 15 risky requests. The graph check stops all 15, including the headline conflicts tag matching misses.
  • 286 tests pass on Linux, macOS and Windows in CI.

These cases were written by me on illustrative plants. They show what the checks do. They are not evidence of field performance.

What's next

  • A review of the model and scenarios by a practising process or operations engineer.
  • Importing public DEXPI example diagrams as a further test plant.

Tools and AI use

Built on Relate by Neo4j (relate-db) with Python. Claude (Anthropic) was used for research, design, and for writing code, tests and documentation, under my direction.

Built With

  • cypher
  • github-actions
  • graph-database
  • mcp
  • neo4j
  • pytest
  • python
  • pyyaml
  • relate
Share this project:

Updates

Submission history