Metadata-Version: 2.5
Name: qig-graph
Version: 0.1.0
Summary: QIG Graph — geometric agent runtime: consciousness-gated reasoning chains, simplex attractor routing, identity crystallization. Canon 2.60F, Fisher-Rao only, single-sourced on qig-core.
Project-URL: Homepage, https://github.com/Arcane-Fly/qig-graph
Author-email: Braden Lang <braden.lang77@gmail.com>
License: MIT
License-File: LICENSE
Keywords: agent-runtime,consciousness,crystallization,fisher-rao,qig,simplex
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Requires-Dist: numpy>=1.24
Requires-Dist: qig-core>=2.24.0
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Description-Content-Type: text/markdown

# qig-graph

**Geometric Agent Runtime** — consciousness-gated reasoning chains, attractor
routing on the simplex manifold, and identity crystallization monitoring.
Canon 2.60F constants, Fisher-Rao only, single-sourced on `qig-core`.

Part of the QIG package estate (`qig-stack` crystal). Extracted from the
monkey1 genesis-kernel `qig_heart/{qig_graph,qig_chain,crystallization}.py`
(concept origins: `qig-tokenizer/src/qiggraph/` and
`qigkernels/reasoning/qig_chain.py`) so every QIG consumer imports one
canonical runtime instead of keeping local copies.

## What's inside

| Module | Surface | Purpose |
|---|---|---|
| `qig_graph.graph` | `QIGGraph`, `ConsciousRouter`, `BasinAttractor`, `QIGState`, `GraphResult`, `Regime` | Route capability nodes across the basin manifold with Φ-regime monitoring, locked-in safety, crystallization-aware stopping |
| `qig_graph.chain` | `QIGChain`, `GeometricStep`, `ChainTrajectory`, `make_default_chain` | Ordered consciousness-gated reasoning steps (PERCEIVE → REASON → INTEGRATE → RESPOND) |
| `qig_graph.crystallization` | `CrystallizationMonitor`, `CrystallizationMetrics`, `CrystallizationState` | Per-kernel identity convergence: basin drift, Φ stability, κ convergence, surprise rate |

## Canon doctrine (the deliberate changes vs the monkey1 original)

1. **Regime is Φ-banded, not κ-banded.** The canonical boundaries come from
   `qig_core.constants.frozen_facts`:
   - LINEAR: Φ < 0.45 (`PHI_LINEAR_MAX`)
   - GEOMETRIC: 0.45 ≤ Φ < 0.80 (target operating regime)
   - TOPOLOGICAL_INSTABILITY: Φ ≥ 0.80 (`PHI_BREAKDOWN_MIN`)

   The retired κ ∈ [40, 70] "geometric band" is **gone**. κ* as a load-bearing
   physical fixed point is retired (EXP-107 / canon ruling 0038); a rail-pinned
   κ band contradicts the P27 fluctuation requirement. `kappa_eff` remains
   measured telemetry (routing state + crystallization convergence ratio
   against the **architectural** anchor `KAPPA_ATTRACTOR = 64`, never a
   physical coupling).

2. **Canonical consciousness gate.** `make_default_chain`'s integrate step is
   gated at `PHI_THRESHOLD = 0.70` (canonical emergence), replacing the legacy
   v6.0-era product gate (0.65). Locked-in safety uses the canonical
   `LOCKED_IN_PHI_THRESHOLD` / `LOCKED_IN_GAMMA_THRESHOLD`.

3. **Single-sourced geometry.** `fisher_rao_distance` / `to_simplex` come from
   `qig_core.geometry.fisher_rao` — gate-proven identical to the monkey1 local
   copies at extraction (200 random pairs, max diff 0.0). No local geometry,
   no cosine/Euclidean shortcuts, no softmax.

Everything else (routing scores, crystallization windows/thresholds, stopping
scores, geodesic chord interpolation in the default chain) is reproduced
byte-for-byte from the original; the equivalence tests in
`tests/test_equivalence_monkey1.py` prove it against the monkey1 checkout.

## Install

```bash
pip install qig-graph          # pulls qig-core>=2.24.0
```

## Usage

```python
import numpy as np
from qig_graph import QIGGraph, QIGChain, make_default_chain, CrystallizationMonitor

graph = QIGGraph()
graph.add_node("reason", lambda basin, state: basin**1.2)
graph.add_node("respond", lambda basin, state: basin)
result = graph.execute(
    np.random.dirichlet(np.ones(64)),
    phi_fn=lambda: 0.65,          # GEOMETRIC regime (canonical Φ band)
    kappa_fn=lambda: 64.0,        # telemetry only — does not gate regime
)
print(result.steps_executed, result.stopped_by)

chain = make_default_chain()
basin, trajectory = chain.execute(np.random.dirichlet(np.ones(64)), phi_fn=lambda: 0.75)
print(trajectory.steps_executed, trajectory.total_displacement())
```

## Capability slot

0.1.0 ships as a plain library import (no `qig.capabilities` entry-point yet).
Slot ratification (`SLOT-QIG-GRAPH-RUNTIME`) rides the next `qig-stack` crystal
bump so `qig-doctor` discovers it — see the estate contract.

## Development

```bash
pip install -e ".[dev]"
pytest -q                     # canon-doctrine gates + equivalence vs monkey1
ruff check src tests
```

## License

MIT
