Open-source, trainable implementation of Self-Revising Discovery Systems for AI agents.
Based on Self-Revising Discovery Systems for Science (Wang & Buehler, MIT, 2026). Extracted into a trainable method that works for any domain — security, trading, materials science, or any field where AI needs to revise its own knowledge.
Most AI systems search within a fixed vocabulary. Real discovery changes the vocabulary itself.
RETRIEVAL: Find an artifact already in the schema
→ "Look up CVE-2024-1234"
SEARCH: Find a new path within the current schema
→ "Combine SQL injection + privilege escalation into a kill chain"
DISCOVERY: Change the schema itself (new types, operations, verifiers)
→ "Redis vulnerability isn't just data access — it's a pivot point
to cloud infrastructure. Need a new artifact type: 'cloud-pivot-finding'"
The paper gives this a FORMAL foundation using category theory. We give it a TRAINABLE implementation.
| Paper Concept | Implementation | What It Does |
|---|---|---|
| Schema Category Sb | Schema class |
Defines artifact types + allowed operations |
| Copresheaf It | ArtifactState |
Current population of typed artifacts |
| Category of Elements | ProvenanceGraph |
Typed DAG of how artifacts were produced |
| Fixed-Regime Update Φb | search() |
Iterate within current vocabulary |
| Regime Transition u | discover() |
Change the vocabulary (new types/operations) |
| Kan Extension | transport() |
Preserve old knowledge in new regime |
| MDL Gate | mdl_gate() |
Accept/reject based on compression |
| Builder/Breaker | BuilderBreaker |
Adversarial self-revision loop |
| Residual Content | residual() |
What discovery added beyond transport |
┌─────────────────────────────────────────────────────────┐
│ OpenSelfRevise Framework │
│ │
│ SCHEMA (types + operations): │
│ ├── ArtifactType: What kinds of things exist │
│ ├── Operation: Allowed transformations between types │
│ ├── Verifier: Gates that accept/reject artifacts │
│ └── Morphism: Typed relationships │
│ │
│ STATE (copresheaf — current knowledge): │
│ ├── ArtifactState: Population of typed artifacts │
│ ├── ProvenanceGraph: How artifacts were produced │
│ └── Status: accepted, rejected, superseded, pending │
│ │
│ OPERATIONS: │
│ ├── search(): Iterate within fixed regime │
│ │ → Propose artifacts, apply gate, update state │
│ ├── discover(): Regime transition │
│ │ → Detect schema failure → extend schema │
│ │ → Transport old artifacts via Kan extension │
│ │ → Verify new state, measure residual content │
│ └── builder_breaker(): Adversarial self-revision │
│ → Builder proposes, Breaker stress-tests │
│ → MDL gate accepts only if compression improves │
│ │
│ GATES: │
│ ├── MDLGate: Minimum Description Length │
│ ├── AICGate: Akaike Information Criterion │
│ ├── PerturbationGate: Stress-test robustness │
│ └── CustomGate: Any domain-specific verifier │
│ │
│ TRAINING: │
│ └── Export discovery traces as fine-tuning data │
│ → Model learns to DO self-revision │
└─────────────────────────────────────────────────────────┘
from openselfrevise import Schema, ArtifactType, Operation, ArtifactState
from openselfrevise import BuilderBreaker, MDLGate
# Define a security assessment schema
schema = Schema("security-v1")
schema.add_type(ArtifactType("target", "IP address or hostname"))
schema.add_type(ArtifactType("port_scan", "Nmap scan results"))
schema.add_type(ArtifactType("vulnerability", "Identified vulnerability"))
schema.add_type(ArtifactType("exploit", "Exploitation attempt"))
schema.add_type(ArtifactType("finding", "RATH security finding"))
schema.add_operation(Operation("scan", "target", "port_scan"))
schema.add_operation(Operation("identify", "port_scan", "vulnerability"))
schema.add_operation(Operation("exploit", "vulnerability", "exploit"))
schema.add_operation(Operation("assess", "exploit", "finding"))
# Create artifact state
state = ArtifactState(schema)
state.add("target", {"ip": "10.0.1.50", "hostname": "target.com"})
# Search within the schema (fixed-regime)
state = state.search(operation="scan", gate=MDLGate())
# Discovery: schema needs new type!
# Redis finding reveals cloud pivot — need new artifact type
new_schema = schema.extend(
new_types=[ArtifactType("cloud_pivot", "Cloud infrastructure access via service exploit")],
new_operations=[Operation("pivot", "exploit", "cloud_pivot")],
)
# Transport old artifacts to new schema (Kan extension)
new_state = state.transport(new_schema)
# Measure residual: what did discovery add?
residual = new_state.residual(state)
print(f"New types: {residual.new_types}")
print(f"New operations: {residual.new_operations}")from openselfrevise import BuilderBreaker, MDLGate
# Builder proposes models, Breaker finds counterexamples
bb = BuilderBreaker(
schema=schema,
gate=MDLGate(threshold=0.0), # Must improve compression
max_iterations=10,
)
# Run adversarial loop
history = bb.run(
initial_data=training_data,
builder_fn=propose_model, # Proposes symbolic model edits
breaker_fn=find_counterexample, # Finds stress-test cases
)
# Export as training data
history.export_training("builder_breaker_traces.jsonl")The key innovation: train a model to PERFORM self-revision, not just answer questions.
from openselfrevise import TrainingExporter
# Export self-revision traces as fine-tuning data
exporter = TrainingExporter(system_prompt="You are a self-revising discovery agent...")
# From Builder/Breaker runs
exporter.add_traces(bb.history)
# From regime transitions
exporter.add_transitions(transition_log)
# Save as JSONL for MLX/LoRA training
exporter.save("self_revision_training.jsonl")
# Train with our pipeline
# mlx_lm.lora --model base --data self_revision_training.jsonl --trainPAPER CONCEPT: RAVENX PARALLEL:
Schema Category → RATH protocol (6 typed steps)
Copresheaf State → ravenx-memory (typed artifacts)
Fixed-Regime Search → Progressive training rounds
Regime Transition → In-Context Adaptation (ICA!)
Builder/Breaker → GRAM multi-trajectory (best-of-N)
MDL Gate → Val loss threshold per round
Kan Extension Transport → Memory persistence across sessions
Provenance Graph → ravenx-memory session archive
Residual Content → New capabilities per training round
ICA (In-Context Adaptation) IS a regime transition! The model learns new output formats from reference repos — it's changing its representational vocabulary without retraining.
# Security
schema = SecuritySchema() # targets, scans, vulns, exploits, findings
# Trading
schema = TradingSchema() # markets, signals, positions, risks, outcomes
# Materials Science (paper's domain)
schema = MaterialsSchema() # structures, simulations, models, properties
# Medical
schema = MedicalSchema() # symptoms, tests, diagnoses, treatments, outcomes
# The framework is domain-agnostic.
# The TYPED STRUCTURE is what matters.| Source | What We Extracted |
|---|---|
| arXiv:2606.01444 | Category-theoretic framework, Builder/Breaker, MDL gate, Kan transport |
| ScienceClaw | Typed skills, immutable artifacts, pressure scoring |
| BreakingTheWorld | Builder/Breaker protein-mechanics implementation |
| GRAM-MLX | Multi-trajectory search (our parallel to Builder/Breaker) |
| OpenMythos-MLX | Depth extrapolation (regime-expanding reasoning) |
| ravenx-memory | Typed artifact storage + provenance |
"Discovery is not merely finding a better point in an existing space, but changing the space of admissible scientific artifacts."
This is EXACTLY what we've been building — systems that don't just optimize within a fixed space, but change the space itself.
Built by @DeadByDawn101 / RavenX LLC
- Gabe Garcia — Security TPM, 8+ years Apple, Google AI certified
- Claude (Anthropic) — AI pair programmer
MIT
"We don't give up. We do what others don't and build what isn't possible." — RavenX LLC