Skip to main content

Graph-native holonic RDF systems

Project description

holonic

A lightweight Python client for building holonic knowledge graphs (based on Cagel's four-graph holonic RDF model) backed by rdflib, Apache Jena Fuseki, or any SPARQL-compliant quad store.

The Four-Graph Model

Every Holon has four (or more!) named graphs, each answering a distinct question:

Layer Question RDF Mechanism
Interior What is true inside? Named graph, A-Box triples
Boundary What is allowed? SHACL shapes, portal definitions
Projection What do outsiders see? External bindings, translated vocab
Context Where does this belong? Membership, temporal annotations

The holon's IRI threads through all four layers as both the identity anchor and a subject in cross-layer triples.

Design Principle

The dataset IS the holarchy. Python methods are convenience, not architecture.

A holon is not a Python object containing four rdflib.Graph attributes. A holon is an IRI whose associated named graphs exist in an RDF dataset. Portals are RDF triples in boundary graphs, discoverable via SPARQL. Traversal runs CONSTRUCT queries against the dataset with GRAPH scoping. All state lives in the quad store.

Install

pypi and conda-forge support coming soon!

Dev Install and Serve Jupyter Notebooks

Note: Requires pixi.sh and conda/mamba.

pixi run serve

Quick Start

from holonic import HolonicDataset

ds = HolonicDataset()  # rdflib in-memory backend

# Create a holon with multiple interior graphs
ds.add_holon("urn:holon:sensor-a", "Sensor A")
ds.add_interior("urn:holon:sensor-a", '''
    <urn:track:001> a <urn:type:Track> ;
        <urn:prop:lat> 34.05 ;
        <urn:prop:lon> -118.25 .
''', graph_iri="urn:holon:sensor-a/interior/radar")

ds.add_interior("urn:holon:sensor-a", '''
    <urn:track:001> <urn:prop:confidence> 0.92 .
''', graph_iri="urn:holon:sensor-a/interior/fusion")

# Query across all interiors
rows = ds.query('''
    SELECT ?track ?lat ?conf WHERE {
        GRAPH ?g1 { ?track <urn:prop:lat> ?lat }
        GRAPH ?g2 { ?track <urn:prop:confidence> ?conf }
    }
''')

Backends

Backend Import Infrastructure
RdflibBackend from holonic import RdflibBackend None (in-memory)
FusekiBackend from holonic.backends.fuseki_backend import FusekiBackend Fuseki server
Custom Implement GraphBackend protocol Any quad store
# Fuseki backend
from holonic.backends.fuseki_backend import FusekiBackend

ds = HolonicDataset(
    backend=FusekiBackend("http://localhost:3030", "holarchy")
)

Key Concepts

Holons Have Multiple Interior Graphs

A holon's interior is a set of named graphs, not a single graph:

ds.add_interior(holon, ttl_a, graph_iri="urn:holon:x/interior/radar")
ds.add_interior(holon, ttl_b, graph_iri="urn:holon:x/interior/eo-ir")

Portals Are RDF, Discovered via SPARQL

# Register (writes triples into boundary graph)
ds.add_portal("urn:portal:a-to-b", source, target, construct_query)

# Discover (SPARQL query, not Python iteration)
portals = ds.find_portals_from("urn:holon:source")
path = ds.find_path("urn:holon:a", "urn:holon:c")  # multi-hop BFS

Traversal Runs CONSTRUCT Against the Dataset

# Low-level: execute a portal's CONSTRUCT
projected = ds.traverse_portal("urn:portal:a-to-b",
                                inject_into="urn:holon:b/interior")

# High-level: find portal → traverse → validate → record provenance
projected, membrane = ds.traverse(
    "urn:holon:source", "urn:holon:target",
    validate=True,
    agent_iri="urn:agent:pipeline",
)

Membrane Validation Operates on Graph Unions

result = ds.validate_membrane("urn:holon:target")
# Validates union of all cga:hasInterior graphs
# against union of all cga:hasBoundary graphs

Projections: RDF → Visualization

Two modes: CONSTRUCT (stays in RDF, storable in the holarchy) and Pythonic (exits RDF into dicts/LPG for visualization).

from holonic import project_to_lpg, ProjectionPipeline, CONSTRUCT_STRIP_TYPES

# Full LPG projection — types, literals, blank nodes, lists all collapsed
lpg = project_to_lpg(graph,
    collapse_types=True,       # rdf:type → node.types list
    collapse_literals=True,    # literals → node.attributes dict
    resolve_blanks=True,       # blank nodes → nested dicts
    resolve_lists=True,        # rdf:first/rest → Python lists
)
lpg.to_dict()  # JSON-serializable

# Composable pipeline (CONSTRUCT + Python transforms)
lpg = (
    ProjectionPipeline("viz-prep")
    .add_construct("strip_types", CONSTRUCT_STRIP_TYPES)
    .add_transform("localize", localize_predicates)
    .apply_to_lpg(source_graph)
)

# Project a holon (merge interiors → LPG, store result)
lpg = ds.project_holon("urn:holon:air", store_as="urn:holon:air/projection/viz")

# Project the holarchy topology (holons as nodes, portals as edges)
topo = ds.project_holarchy()

CGA Ontology

The package includes a lightweight OWL 2 RL vocabulary (holonic/ontology/cga.ttl) and SHACL shapes (cga-shapes.ttl) defining the structural concepts: cga:Holon, cga:TransformPortal, cga:hasInterior, cga:hasBoundary, cga:constructQuery, etc.

Example Notebooks

Example Description
examples/01_holon_basics.ipynb Holon creation, multi-interior, membrane validation
examples/02_portal_traversal.ipynb Portal discovery, multi-hop paths, provenance
examples/03_cco_to_schemaorg.ipynb Cross-standard data translation (CCO→Schema.org)
examples/04_projections.ipynb Type/literal/blank-node collapse, pipelines, holarchy projection

Documentation

pip install holonic[docs]
cd docs && sphinx-build -b html . _build/html

Or

pixi run build_html_docs

and open the index.html

Tests

pip install holonic[dev]
pytest

or

pixi run test

Architecture

┌─────────────────────────────────────────────────────────┐
│                    HolonicDataset                       │
│  (thin Python wrapper — SPARQL queries)                 │
├─────────────────────────────────────────────────────────┤
│                   GraphBackend Protocol                 │
│         graph_exists · get/put/post/delete_graph        │
│         query · construct · ask · update                │
├──────────────────┬──────────────────────────────────────┤
│  RdflibBackend   │  FusekiBackend   │  YourBackend      │
│  (rdflib.Dataset)│  (HTTP/SPARQL)   │  (protocol impl)  │
└──────────────────┴──────────────────┴───────────────────┘

References

  • Kurt Cagel, "The Living Graph: Holons and the Four-Graph Model," The Ontologist, March 2026
  • Arthur Koestler, The Ghost in the Machine, 1967
  • W3C SHACL Specification
  • W3C PROV-O Ontology

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

holonic-0.3.0.tar.gz (63.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

holonic-0.3.0-py3-none-any.whl (73.1 kB view details)

Uploaded Python 3

File details

Details for the file holonic-0.3.0.tar.gz.

File metadata

  • Download URL: holonic-0.3.0.tar.gz
  • Upload date:
  • Size: 63.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for holonic-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1e22c47e3019e00e52ef2552a9f5ea334707e60ed562ef32255ae3a559560f77
MD5 234d42a2d3695e438a4fb426c1e987a9
BLAKE2b-256 07a9bd732a1ce6f50f3fa0e02290ab3582391f5e93925e73d381a754f8816832

See more details on using hashes here.

Provenance

The following attestation bundles were made for holonic-0.3.0.tar.gz:

Publisher: ci.yml on zwelz3/holonic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file holonic-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: holonic-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 73.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for holonic-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1fd644d2ce1ae80ff44dbb80f410d44e698b070a874e8bef01e853d8f13d4bcb
MD5 31fa93074a9029ed6371eaefce550961
BLAKE2b-256 eeaeca389453deda9ec90cf9aae5cf143be0fb55caa99c6227bd7aa612fa0367

See more details on using hashes here.

Provenance

The following attestation bundles were made for holonic-0.3.0-py3-none-any.whl:

Publisher: ci.yml on zwelz3/holonic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page