gitwtfhub

wtf is twingraph?

parisi-labs/twingraph — explained in plain English

Analysis updated 2026-05-18

21PythonAudience · developerComplexity · 4/5Setup · moderate

TL;DR

A lightweight Python format for describing how real systems like power grids work, so software can check decisions against it without running anything itself.

Mindmap

Mindmap is still cooking. Refresh in a few.

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Model a battery storage or power grid system as a typed, checkable document.

REASON 2

Validate that a proposed operational decision satisfies defined constraints before it runs.

REASON 3

Pass a stable, versioned description of a real system between different teams or tools.

REASON 4

Build a custom runtime that executes plans TwinGraph has already validated.

What's in the stack?

Pythonpydantic

How it stacks up

parisi-labs/twingraph0whitedev/detranspiler2951461586/mulerun-pool
Stars212121
LanguagePythonPythonPython
Setup difficultymoderatehardmoderate
Complexity4/54/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · moderate Time to first run · 30min

Not yet on PyPI, so it must be installed directly from GitHub.

Wtf does this do

TwinGraph is a small Python package for describing how a real operating system works in a way that both people and software can inspect. Think of it as a shared blueprint format for things like power grids or battery storage systems: it records what equipment exists, how the pieces connect, what is being measured, what can be controlled, what data is available when a decision needs to be made, which prediction models are referenced, and what rules make a decision valid. It is important to understand what TwinGraph is not. It does not run simulations, optimize anything, store data long term, or provide a user interface. It only defines the structure of the information, called an intermediate representation. The package itself depends on almost nothing else, just Python's standard library plus a validation library called pydantic, which keeps it lightweight and easy to trust. A TwinGraph document is built from ten basic building blocks: entities (the objects involved), relations (how they connect), variables (things that change or are measured), data bindings (where live data comes from), model bindings (references to prediction or analysis models), actions (things that can be controlled), constraints, objectives, validators, and evidence. A function called compile_graph checks that all these pieces fit together correctly, catching problems like unknown types, broken references, or mismatched units, without actually running anything. If the document passes this check, TwinGraph produces a plan describing what should happen, but leaves the actual execution to whatever software the user builds separately. The project also ships some ready made vocabularies for common domains, covering things like batteries, solar and wind power, transformers, and data center equipment such as racks and cooling systems. This is aimed at developers building operational or industrial software who need a dependable, well defined format to pass information between real world sensors and decision making systems, rather than end users looking for a finished application.

Yoink these prompts

Prompt 1
Show me how to define a TwinGraph document with entities, variables, and constraints for a simple battery system.
Prompt 2
Explain what compile_graph checks for and what diagnostic codes like TG_UNIT_MISMATCH mean.
Prompt 3
Help me register a custom model reference and IOContract for use with TwinGraph.
Prompt 4
Walk me through the public physical BESS example referenced in the twingraph README.

Frequently asked questions

wtf is twingraph?

A lightweight Python format for describing how real systems like power grids work, so software can check decisions against it without running anything itself.

What language is twingraph written in?

Mainly Python. The stack also includes Python, pydantic.

How hard is twingraph to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is twingraph for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.