zinet
Graph IR core package shared across SPL, ConceptBook, Graph-Code, Momagrid, and Solver domains.
graph.yaml is the common intermediate representation of the ZiNets ecosystem, the way LLVM IR
is for compilers: front-ends emit it, back-ends consume it, and the shared validator and
transforms live here once.
The format
Every graph has three layers, each a list of nodes:
version: "1.0"
imports: [./shared/tools.yaml] # optional; resolved relative to this file
primitives: # leaves: must not have deps
- id: x_units
meta: {type: variable}
concepts: # composed from primitives and other concepts
- id: capacity_constraint
deps: [x_units, max_units]
edge_types: {max_units: constraint}
meta: {expression: "x_units <= max_units"}
applications: # capstones: nothing may depend on these
- id: minimize_cost
deps: [capacity_constraint]
depsare the ids a node depends on (incoming edges).edge_typesoptionally types a dependency:depends_on(default),data_flow,prerequisite,constraint,inheritance.metais an opaque domain payload that the core never interprets.
Install
From PyPI:
pip install zinet
From source, for development:
uv venv .venv && uv pip install -p .venv/bin/python -e ".[dev]"
CLI: zinet
zinet validate graph.yaml # exit 1 on errors; warnings are printed but do not fail
zinet diff old.yaml new.yaml # exit 1 when the graphs differ
zinet slice graph.yaml target_id -o part.yaml # target plus its prerequisite closure
zinet render graph.yaml # svg to stdout (default)
zinet render graph.yaml --format mermaid # mermaid flowchart text
zinet render graph.yaml --format png -o graph.png # png and pdf need -o
zinet prettify graph.yaml # diff against canonical formatting (exit 1 if it would change)
zinet prettify graph.yaml --write # rewrite in place (refuses files with comments)
zinet schema -o schemas/graph.schema.json # JSON Schema for editors and other tools
render supports svg, png, pdf, and mermaid. Mermaid needs nothing installed. The
other formats need Graphviz's dot on PATH (apt install graphviz).
Exit code 2 means a usage, load, or render error. prettify exits 1 when a file is not in
canonical form, so it can run in CI.
Specification
The format is specified in docs/SPECIFICATION.md. The machine-readable
JSON Schema is schemas/graph.schema.json, regenerated with
zinet schema -o schemas/graph.schema.json. A test fails if the committed schema is out of date.
Python API
from zinet import load_graph, validate, diff_graphs, slice_to, dump_graph
graph = load_graph("solver_pipeline.yaml") # resolves imports
for issue in validate(graph):
print(issue)
prereqs = slice_to(graph, "minimize_cost")
Checks
| Code | Severity | Meaning |
|---|---|---|
duplicate_id |
error | an id is defined more than once |
unknown_dep |
error | a dep names an id that does not exist |
primitive_has_deps |
error | a primitive depends on something |
layer_violation |
error | a node depends on an application |
cycle |
error | the dependency graph is not a DAG |
orphan |
warning | a node with no deps and no dependents |
Layout
src/zinet/
schema.py Pydantic models: Graph, Node, Layer, EdgeType
dag.py topological order, ancestors (domain-agnostic)
validator.py structural checks -> Issue list
io.py load_graph (with imports), dump_graph, to_yaml
prettify.py canonical formatting for `zinet prettify`
transforms/ diff_graphs, slice_to
render.py DOT and Mermaid generation, svg/png/pdf via `dot`
cli.py the `zinet` command
docs/SPECIFICATION.md the graph.yaml format specification
schemas/graph.schema.json generated JSON Schema
tests/ pytest suite; tests/fixtures holds one graph per domain
Design decisions
- Imports merge nodes without namespacing, so ids must be unique across the whole import tree.
load_graphdoes not validate. Runvalidateseparately for structural checks.- Unknown top-level and node keys are rejected, so typos fail loudly. Domain data goes in
meta. - Only the core checks are here. Domain rules (for example, solver bounds) belong in the back-end.
Not yet implemented
- Domain-specific JSON Schema overlays (solver, spl, cba).
graph.htmlinteractive explorer (belongs tocba).- Comment-preserving formatting.
prettify --writerefuses files with comments. spl3integration, which is the next step: SPL scripts compiling toGraphIR.
Metadata
Release files for zinet 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| zinet-0.1.0.tar.gz | 24.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zinet-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.2 kB
Release files / zinet-0.1.0.tar.gz
| Download URL | zinet-0.1.0.tar.gz |
|---|---|
| Size | 24.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
101fde21a6b7d62583006a7137cad1f6c0584df35785ee4c21985a6677279f52
|
|
BLAKE2b-256 checksum How to use checksums |
8106d0eccb8e7d7071f01663608fa7af6ef79db88ed26e8ef614d238ec8c9bdd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / zinet-0.1.0-py3-none-any.whl
| Download URL | zinet-0.1.0-py3-none-any.whl |
|---|---|
| Size | 23.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03209a65e00146c65e7eade38b7a6d065c5782f5dc0ef0396e61f9fa2f476375
|
|
BLAKE2b-256 checksum How to use checksums |
178c38e3614cdcccdc7ee184db86ce228b49a5dac467bc56f4f818418ea69ab6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for zinet 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.