Skip to main content

Belief Revision System (BRS)

PyPI version Python versions License Release

A maximally general framework for managing, revising, and reasoning about belief systems.

Overview

BRS provides domain-agnostic infrastructure for:

  • Versioned Knowledge Graphs: Immutable, content-addressable storage of nodes, edges, patterns, and world bundles
  • Cross-Domain Discovery: Pattern matching via pluggable similarity metrics to find analogies between domains
  • Non-Destructive Evaluation: Shadow worlds for hypothesis testing without affecting canonical beliefs
  • Pluggable Domain Extensions: Auto-discovered smoke tests and domain-specific validators

Architecture

Mermaid source
graph TD
    subgraph Extensions["Domain Extensions"]
        W["Writing_smoke.py"]
        B["Biology_smoke.py"]
        Y["Your Domain_smoke.py"]
    end

    W & B & Y --> R["Registry(auto-discovery)"]

    subgraph Core["Core Framework"]
        R --> E["Evaluator(smoke tests)"]
        D["Discovery(mesh/sim)"] --> E
        E --> D
        E --> V["Revision(shadow)"]
        V --> E
        D & E & V --> I["Inference(graph traversal)"]
        I --> S["Storage(CAS + SQLite)"]
        S --> C["Core(types + utilities)"]
    end

Installation

pip install py-brs

For development:

pip install -e .

Quick Start

from pathlib import Path
from brs import CASStore, Node, Edge, Pattern, WorldBundle

# Initialize storage
store = CASStore(Path("./my_knowledge_base"))

# Create a node
node = Node(
    id="CONCEPT_A",
    name="My Concept",
    node_type="primary",
    properties={"category": "example"}
)
h = store.put_object("Node", node)
store.upsert_node(node.id, node.name, h)

# Create an edge
edge = Edge(
    id="EDGE_1",
    parent_id="ROOT",
    child_id="CONCEPT_A",
    relation="derived_from",
    tier=0,
    confidence=0.95
)
h = store.put_object("Edge", edge)
store.upsert_edge(edge.id, edge.parent_id, edge.child_id,
                  edge.relation, edge.tier, edge.confidence, h)

# Create a world bundle
world = WorldBundle(
    domain_id="my_domain",
    version_label="green",
    node_ids=("ROOT", "CONCEPT_A"),
    edge_ids=("EDGE_1",),
    evidence_ids=(),
    pattern_ids=(),
    created_utc="2025-01-27T00:00:00Z"
)
store.put_world(world)

# Query ancestry
from brs import best_path_to_any_root
result = best_path_to_any_root(store, "CONCEPT_A", ["ROOT"])
print(result.explanation)

store.close()

Key Concepts

World Bundles

Immutable snapshots of a domain's belief state. Multiple versions can coexist (e.g., "green" for canonical, "_shadow_eval" for testing).

Patterns

Capture invariants and operators that should hold across the domain. Used for cross-domain analog discovery.

Mesh Discovery

Find analogies between domains by comparing pattern signatures using Jaccard similarity or custom metrics.

Shadow Evaluation

Fork a world, apply a proposed change, run smoke tests, and compare maturity—all without affecting canonical beliefs.

Creating Domain Extensions

Add a file brs/domains/my_domain_smoke.py:

DOMAIN_ID = "my_domain"

def run(store, domain_id, world_label):
    """Smoke tests for my domain."""
    tests, failures, messages = 0, 0, []

    # Your invariant checks here
    tests += 1
    # if check_something_fails:
    #     failures += 1
    #     messages.append("FAIL: ...")
    # else:
    messages.append("OK: Domain invariants hold")

    return (tests, failures, messages)

SMOKE_LEVELS = {
    "smoke": run,        # Fast checks
    "regression": run,   # Medium checks
    "deep": run,         # Expensive checks
}

The domain will be auto-discovered and registered when the brs.domains package is imported.

CLI Usage

# List worlds
brs worlds

# Show domain statistics
brs stats my_domain

# Run smoke tests
brs smoke my_domain --level smoke --verbose

# Discover cross-domain analogs
brs discover domain_a domain_b --min-score 0.3

# Evaluate a proposal
brs evaluate PROPOSAL_ID my_domain --verbose

Components

Module Purpose
core Type definitions (Node, Edge, Pattern, WorldBundle, Maturity)
storage Content-addressable SQLite backend
mesh Pattern signatures and similarity metrics
inference Graph traversal (ancestry, reachability)
revision Shadow imports and evaluation
discovery Cross-domain analog suggestion
evaluator Smoke test orchestration
domains Auto-discovered domain extensions
cli Command-line interface

License

MIT

Metadata

Release files for py-brs 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-brs 2.0.0
File Size Uploaded Provenance Actions
py_brs-2.0.0.tar.gz 44.9 kB With provenance Details for py_brs-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-brs 2.0.0
File Interpreter ABI Platform Actions
py_brs-2.0.0-py3-none-any.whl Python 3 none any Details for py_brs-2.0.0-py3-none-any.whl

Total release size: 87.5 kB

Release files / py_brs-2.0.0.tar.gz

Download URL py_brs-2.0.0.tar.gz
Size 44.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c427929a40258c1d3752d5ca1597960c65453de191c5b7877d16fd71b4ef687e
BLAKE2b-256 checksum
How to use checksums
33bbbcb9a414aed48a368bbd7464b592ed40f6363f319db0683fab9bf1532920
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 27, 2026.

Transparency log

Release files / py_brs-2.0.0-py3-none-any.whl

Download URL py_brs-2.0.0-py3-none-any.whl
Size 42.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b49559f16d56de7bda0fb7583dd2cd56d6e64554081aa1ba93d4f2e085839ac
BLAKE2b-256 checksum
How to use checksums
1a59a5efa0ebfa40f34aff6359bc8d5d69a7242dd1d76d867e1626fbbf9faa5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 27, 2026.

Transparency log

Security for py-brs 2.0.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for py_brs-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 27, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page