Skip to content

05 / Stochastic simulation library

OSAHRResearch

Replay a changing system.

An open-source Python library for exact stochastic simulation of networks that change their own structure, with seeded, hash-checked replay.

Rules rewrite a typed directed hypergraph at random times with exact probabilities. Three schedulers, incremental pattern matching checked against an exhaustive matcher, adaptive parameters, and a replay that reproduces every recorded state hash. Every public claim is graded Known, Measured, Inferred or Proposed.

Why

Why a kernel for networks that rewrite themselves.

Most simulators change the state of a fixed network. Many real systems change the network itself: a cell grows a connection, an organisation adds a role, an agent fleet forms a new channel. Modelling that exactly, with the right probabilities and a record you can replay, is the problem OSAHR takes on.

The kernel is deliberately small and dependency-free so its invariants can be stated and checked. The adaptive, replayable network it provides is the primitive the lab’s governed-work infrastructure is designed to sit on; the seam between them is specified before it is built.

Use

What you can do

pip install the wheel, or run the examples from a checkout.

  1. 01 / Model

    Declare a typed hypergraph

    A schema, a graph, and rules written as pattern → template with a rate expression and optional adaptation of parameters and memory.

  2. 02 / Run

    Choose a scheduler

    Direct SSA, modified next-reaction, or bounded thinning. All three are exact; incremental matching is checked against an exhaustive matcher.

  3. 03 / Replay

    Reproduce every state

    Seeded runs reproduce their trace, and delta replay reproduces every recorded state hash. The site’s own OSAHR map was exported this way.

  4. 04 / Review

    Graded evidence packets

    The decision workbench turns frozen experiments into reviewable packets. GrokCell is a prototype agent control plane on the same kernel.

Inspect

A hypergraph, one committed event at a time.

Recorded by running the adaptive-signal example and exported from the trace. Every state is hashed; the replay reproduces every hash.

This map needs JavaScript. It replays a recorded run: two agents exchanging typed signal hyperedges, parameters adapting as rules fire, and the state hash after every committed event.

Recorded run

Twenty-five events, one hash to replay.

The repository’s own example, run on 2026-10-05 from OSAHR_Cell@7293e27 with Python 3.11 in a fresh venv after python -m pip install -e . No dependencies, no network.

python examples/adaptive_signal.py

events: 25
simulation time: 10.000000
agents: 2
receiver: {'active': True, 'value': 2.5, 'responsiveness': 1.0}
memory: {'received_count': 10, 'intensity_ema': 0.17478781247500003}
state hash: 6d73af0a24684c9afc339e1bc59dddbd6ca42a08792fca5b8b7e123fc262a857
Complete output, unedited. From seed 20260729 the kernel committed 25 events in ten units of simulated time: two agents, ten signals received, the receiver’s value raised to 2.5 and its responsiveness driven from 0.1 to the clip at 1.0 by an injected external event at t = 3 and the rule’s own adaptation. The state hash is the canonical hash of the final state; a second run from the same seed prints the same lines, and the Inspect map above was exported from this same run. In the same checkout python -m pytest tests reported 127 passed, 1 skipped in 30 s (the skip is the optional ontology probe, which needs rdflib). This is a research model of a mechanism with illustrative parameters, not a calibrated forecast of any real system.

Design

How it is built

  • Exact stochastic rewriting

    Continuous-time rules over a typed directed hypergraph, with the invariants written down in the architecture document.

  • Incremental matching

    Incidence-constrained pattern search keeps matching fast as the graph grows and is cross-checked against an exhaustive matcher.

  • Adaptive parameters

    Rules can rewrite the model’s own parameters and memory, so the dynamics change as the structure does.

  • No runtime dependencies

    Python 3.11+ only in the core; experiments are confirmatory records on the kernel.

Evidence

  • Tested

    A pytest suite of 41 test files across the kernel, experiments and workbench; the kernel suite (tests/) passed 127 of 128 on 2026-10-05, the one skip being the optional ontology probe. Replay of the site’s recorded trace reproduces every state hash.

  • Implemented

    Kernel, three schedulers, incremental matching, adaptive parameters, replay, the decision workbench and the GrokCell prototype.

  • Not yet

    Research models of mechanisms, not calibrated forecasts. No continuous integration is configured in the repository yet.

Reflects SyberLabs/OSAHR_Cell@7293e27 · verified 2026-10-05. Each state is earned by code, a named test, a measurement under stated conditions, or a deployment; none is promoted by wording.

Facts

Status
Research
Stage
Open-source research library, version 0.2.1
Technology
Python 3.11+ (no runtime dependencies in the core library), pytest
Scope
Research models of mechanisms, not calibrated forecasts
License
Apache 2.0 in the LICENSE file; pyproject.toml’s metadata still says MIT

Other projects

All work