Metadata-Version: 2.5
Name: operon-ai
Version: 0.40.0
Summary: Functorial pattern spaces and verifiable interfaces for robust agentic systems.
Project-URL: Homepage, https://github.com/coredipper/operon
Project-URL: Documentation, https://banu.be/operon/
Project-URL: Repository, https://github.com/coredipper/operon
Project-URL: Changelog, https://banu.be/operon/releases/
Author-email: Bogdan Banu <bogdan@banu.be>
License-Expression: MIT
License-File: LICENSE
Keywords: agents,biology,category-theory,llm,reliability
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Requires-Dist: pydantic>=2.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == 'dev'
Provides-Extra: eval
Requires-Dist: agentdojo>=0.1.35; extra == 'eval'
Requires-Dist: bfcl-eval>=2026.2; extra == 'eval'
Requires-Dist: datasets>=4.0; extra == 'eval'
Requires-Dist: swebench>=3.0; extra == 'eval'
Provides-Extra: langgraph
Requires-Dist: langchain-openai>=0.1.0; extra == 'langgraph'
Requires-Dist: langgraph>=0.2.0; extra == 'langgraph'
Provides-Extra: llm
Requires-Dist: anthropic>=0.18.0; extra == 'llm'
Requires-Dist: google-genai>=1.0.0; extra == 'llm'
Requires-Dist: openai>=1.0.0; extra == 'llm'
Description-Content-Type: text/markdown

# Operon 🧬

**Functorial pattern spaces and verifiable interfaces for reliable AI agent systems**

> *From cellular metaphor sprawl toward typed interfaces, cognitive light cones, and verifiable structural guarantees.*

![Status](https://img.shields.io/badge/status-experimental-orange)
[![PyPI version](https://img.shields.io/pypi/v/operon-ai?color=blue&label=pypi)](https://pypi.org/project/operon-ai/)
![License](https://img.shields.io/badge/license-MIT-green)
[![Publish to PyPI](https://github.com/coredipper/operon/actions/workflows/publish.yml/badge.svg)](https://github.com/coredipper/operon/actions/workflows/publish.yml)

---

## Core Direction (v0.40+)

Most agent systems fail structurally, not locally: correlated hallucinations slip past same-model reviewers, sequential chains accumulate handoff loss, fragmented toolsets incur $O(t \cdot n)$ discovery overhead, and unguarded loops exhaust budgets.

Rather than mirroring every organelle of a eukaryotic cell into software boilerplate, Operon follows the **structural core** of Michael Levin's *Ingressing Minds* (*Philosophies* 2026, 11(5):161)—and supplies the **Applied Category Theory** it lacks:

- **Pattern Space as Typed Wiring + Replayable Invariants (`PatternSpec`):** Control patterns live in an abstract operad of typed wiring diagrams paired with mechanically replayable `Certificate` obligations.
- **Embodiments as Pointer Functors (`Realization`):** Natural, synthetic, and hybrid runtimes realize patterns via strict or lax monoidal functors. **Strict realization** transfers structural guarantees for free (Levin's *"free lunches"*); **lax realization** quantifies degradation explicitly (correlation $\rho$ in conjunctive verification, Data Processing Inequality handoff loss $\Delta I$, or embedding fidelity).
- **Bi-Temporal Cognitive Light Cones (`CognitiveLightCone` + `BiTemporalMemory`):** Combines optic-filtered wiring observations (`obs_i`) with valid-time and record-time horizons `(t_v, t_r)` to analyze multi-agent scaling and reconstruct exact past belief states.
- **Polycomputing Fibers (`PolycomputingFiber`):** Multiple pattern realizations sharing one physical/computational substrate through commuting read/write lenses.

*(Scope note: Operon adopts methodological structuralism—formalizing pattern spaces, interfaces, and light cones mathematically while staying agnostic on phenomenal consciousness; full engagement with Levin's non-physicalist consciousness claims is reserved for future work.)*

---

## Five-Layer Architecture

Operon's canonical API is streamlined to **~65 focused exports** across five layers:

| Layer | Module | Responsibility |
|---|---|---|
| **1. Core** | `operon_ai.core` | `WiringDiagram`, `Optic`, `BarrierFilter`, `Coalgebra`, `PatternSpec`, `Realization`, `LaxityReport`, `PolycomputingFiber`, `Certificate`, `CognitiveLightCone`, `epistemic_analyze` |
| **2. Memory** | `operon_ai.memory` | `BiTemporalMemory`, `BiTemporalFact`, `BiTemporalQuery` (canonical append-only dual-axis store) |
| **3. Motifs** | `operon_ai.motifs` | Proven control motifs only: `ReviewerGate` (CFFL), `QuorumSensingBio` (decay), `Chaperone` / `ChaperoneLoop`, `ATP_Store` / `MTORScaler` / `DNARepair` / `Genome`, `ImmuneSystem` / `StagnationMonitor`, `DiffusionField`, `Tissue` / `TissueBoundary`, `PlasmidRegistry` |
| **4. Runtime** | `operon_ai.runtime` | Single composable runtime (`SkillOrganism`, `SkillStage`, `SpecialistSwarm`, `WatcherComponent`, `VerifierComponent`, `CertificateGateComponent`, `advise_topology`, `Nucleus`, providers) |
| **5. Adapters** | `operon_ai.adapters` | `ExternalTopology` IR, `CompilerFunctor`, LangGraph & A2A/GasCity/AgentFlow/DSPy certificate contracts (`operon_ai.adapters.contrib` holds exploratory framework wrappers) |

> **Backward Compatibility:** Deprecated cellular-roleplay wrappers (`Ribosome`, `Lysosome`, `Telomere`, `IntegratedCell`, `HistoneStore`) and renamed protocols (`DenatureFilter` → `BarrierFilter`, `EpiplexityMonitor` → `StagnationMonitor`) remain available via PEP 562 lazy shims on `operon_ai` (with `DeprecationWarning`) and under `operon_ai.legacy`.

---

## Installation

```bash
pip install operon-ai
```

---

## Quick Start

### 1. Define a Pattern, Verify Strict vs. Lax Realization, and Query a Cognitive Light Cone

```python
from datetime import datetime, timezone
from operon_ai import (
    ATP_Store, BiTemporalMemory, CognitiveLightCone,
    DataType, IntegrityLabel, ModuleSpec, PatternSpec,
    PortType, Realization, WiringDiagram,
)

diagram = WiringDiagram()
diagram.add_module(ModuleSpec("generator", outputs={"draft": PortType(DataType.TEXT)}))
diagram.add_module(ModuleSpec("reviewer", inputs={"draft": PortType(DataType.TEXT)}))
diagram.connect("generator", "draft", "reviewer", "draft")

pattern = PatternSpec(
    name="conjunctive_review_gate",
    diagram=diagram,
    obligations=("priority_gating",),
    axioms=("independent_verifier",),
)

budget = ATP_Store(budget=100, silent=True)
realization = Realization(
    pattern=pattern,
    substrate_kind="hybrid",
    bindings={"generator": "llm:fast", "reviewer": "symbolic:validator"},
    certificates=(budget.certify(),),
)

report = realization.verify_ingression(lax_defects={"verifier_correlation_rho": 0.0})
assert report.strict and report.all_certificates_hold

cone = CognitiveLightCone.from_diagram(diagram, "reviewer", record_horizon=datetime.now(timezone.utc))
print(cone.spatial_width, cone.observable_modules)
```

### 2. Pattern-First Agent Runtime & Topology Advice

```python
from operon_ai import (
    BiTemporalMemory, MockProvider, Nucleus, SkillStage,
    TelemetryProbe, advise_topology, reviewer_gate, skill_organism,
)

advice = advise_topology(task_shape="sequential", tool_count=2, subtask_count=3, error_tolerance=0.02)
print(advice.recommended_pattern, advice.suggested_api)

gate = reviewer_gate(
    executor=lambda prompt: f"EXECUTE: {prompt}",
    reviewer=lambda prompt, candidate: "safe" in prompt.lower(),
)
print(gate.run("Deploy safe schema migration").allowed)

fast = Nucleus(provider=MockProvider(responses={"route": "EXECUTE: billing"}))
deep = Nucleus(provider=MockProvider(responses={"billing": "EXECUTE: escalate"}))
organism = skill_organism(
    stages=[
        SkillStage(name="intake", role="Normalizer", handler=lambda task: {"request": task}, emit_output_fact=True),
        SkillStage(name="router", role="Classifier", instructions="route", mode="fixed"),
        SkillStage(name="planner", role="Planner", instructions="Use routing result.", mode="fuzzy"),
    ],
    fast_nucleus=fast,
    deep_nucleus=deep,
    substrate=BiTemporalMemory(),
    components=[TelemetryProbe()],
)
print(organism.run("Refund missing").final_output)
```

### 3. Framework-Neutral Portability & Certificates

```python
from operon_ai.adapters import ExternalTopology, analyze_external_topology, langgraph_functor
from operon_ai.convergence.langgraph_compiler import run_organism_langgraph
```

---

## Theory, Papers & Resources

Seven focused papers and the updated archival monograph live in [`article/`](article/README.md):

- **[Monograph (`article/monograph.pdf`)](article/monograph.pdf):** *Biological Motifs for Agentic Control* — functorial interface theory, correlated-error CFFL bounds, bi-temporal epistemic topology, equational diagram rewriting, and empirical boundary conditions.
- **[Paper 7 (`article/paper7/main.pdf`)](article/paper7/main.pdf):** *Categorical Semantics of Ingressing Patterns* — dedicated category-theoretic formalization of Levin (2026) (*Ingressing Minds*).
- **[Papers 1–6 (`article/README.md`)](article/README.md):** Epistemic topology, cross-framework convergence, meta-level generalization negative results, 10M+ trial structural-guarantee benchmarks (`arXiv:2605.15225`), categorical harness compilation (`arXiv:2605.12239`), and reflective evolution variance analysis.
- **[Core 12 Canonical Examples](examples/README.md)** (plus full historical example archive).
- **Public Documentation:** [banu.be/operon](https://banu.be/operon/) (`docs/site/`).

## License

MIT
