Skip to main content

Belief Revision System - A maximally general framework for managing and revising belief systems

Project description

Belief Revision System (BRS)

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

┌────────────────────────────────────────────────────────────────────┐
│                         Domain Extensions                           │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐             │
│  │   Writing    │  │   Biology    │  │  Your Domain │             │
│  │  _smoke.py   │  │  _smoke.py   │  │  _smoke.py   │             │
│  └──────────────┘  └──────────────┘  └──────────────┘             │
│           │               │               │                        │
│           └───────────────┴───────────────┘                        │
│                           │                                        │
│                    ┌──────▼──────┐                                 │
│                    │  Registry   │  (auto-discovery)               │
│                    └──────┬──────┘                                 │
├────────────────────────────┼───────────────────────────────────────┤
│                            │                                       │
│  ┌──────────────┐  ┌───────▼──────┐  ┌──────────────┐             │
│  │  Discovery   │──│  Evaluator   │──│   Revision   │             │
│  │  (mesh/sim)  │  │ (smoke tests)│  │   (shadow)   │             │
│  └──────────────┘  └──────────────┘  └──────────────┘             │
│           │               │               │                        │
│           └───────────────┴───────────────┘                        │
│                           │                                        │
│                    ┌──────▼──────┐                                 │
│                    │  Inference  │  (graph traversal)              │
│                    └──────┬──────┘                                 │
│                           │                                        │
│                    ┌──────▼──────┐                                 │
│                    │   Storage   │  (CAS + SQLite)                 │
│                    └──────┬──────┘                                 │
│                           │                                        │
│                    ┌──────▼──────┐                                 │
│                    │    Core     │  (types + utilities)            │
│                    └─────────────┘                                 │
└────────────────────────────────────────────────────────────────────┘

Installation

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

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

py_brs-1.0.1.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

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

py_brs-1.0.1-py3-none-any.whl (38.9 kB view details)

Uploaded Python 3

File details

Details for the file py_brs-1.0.1.tar.gz.

File metadata

  • Download URL: py_brs-1.0.1.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for py_brs-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8871f50195a3771af981723f6186eb7cf6f7559068d9208f105672d7e10ff71a
MD5 d40f4c336227db2901795fc6a4aadb7f
BLAKE2b-256 855fc5a082410b380f741ccd4e0662c38687e706284bcbcc635a69aef7489b93

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_brs-1.0.1.tar.gz:

Publisher: release.yml on egoughnour/brs

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

File details

Details for the file py_brs-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: py_brs-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 38.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for py_brs-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 efb1680b109f486198958b3589b130414986e1569c90552a779a0d957c2ea126
MD5 fc6557f371d7488cf848d2dad5787f57
BLAKE2b-256 dafc0a0734da6ac4f41bce4acca7d30ca6208554dcc3b9cc26d5c873df8ef5ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_brs-1.0.1-py3-none-any.whl:

Publisher: release.yml on egoughnour/brs

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