Skip to content

graevka-lab/arctl

Repository files navigation

arctl: Adaptive Resonance Control

License: MIT Status: Experimental Tests

"Code is for machines. Resonance is for intelligence."

1. Phase Space Trajectory (3D)

Visualizing the system's movement through Repetition (X), Energy (Y), and Temperature (Z). Phase Space

2. Intervention Telemetry (2D)

Real-time monitoring of repetition loops and thermal spikes. Telemetry Demo

arctl is a hybrid control architecture for LLM inference, combining:

  1. Hard Core β€” a deterministic state machine for physical sampling control.
  2. Soft Core β€” a semantic resonance engine for latent space steering.

🎯 The Problem: Chaos in the Latent Space

Modern LLMs suffer from three fundamental flaws:

  1. The Knowledge Dump: Training data is "emotionally polluted". Technical specs are mixed with fiction.
  2. Temporal Blindness: Models confuse Past, Present, and Future because they live in discrete time.
  3. Lack of Control: There is no mechanism to manage the "Pattern of Thought" (e.g., force a specific emotional mix).

The Experiment: Ask an LLM to explain "Pulse Width Modulation" (PWM) with different emotional overlays:

  • Joy: "PWM is a dance of signals!" (Metaphorical distortion).
  • Fear: "PWM is dangerous, circuits might explode!" (Risk hallucination).
  • Calm: "PWM controls power via duty cycle." (Technical truth).

Conclusion: Hallucinations are often Resonance Errors. To fix this, we need to enforce the correct Resonance Profile (a precise mix of emotions) for each task.


πŸ› οΈ The Solution: Hybrid Control Anchored in Physics

We cannot rebuild the dataset (yet). But we can control the Resonance Profile of the inference.

Production-ready: Hard Core (kernel + Chronos + Icarus). Proof of concept: Soft Core (resonance engine).

arctl v1.3.1 implements a two-layer control system, anchored by Project Icarus and Chronos T-SPIRAL_ALIGNMENT:

1. The Hard Core (Kernel)

A deterministic Python state machine, now stabilized by the Icarus Geometric Anchor.

  • Role: The Bodyguard.
  • Function: Monitors entropy and repetition. It no longer just reacts to chaos; it actively forces the system's state to "tunnel" back towards a stable equilibrium, using the calculate_tunneling_vector logic. Failure (FALLBACK) is still explicit, but now it's the last line of defense, not the first.
  • Philosophy: Stability is not a goal; it is a non-negotiable initial condition.
  • Spec: Core transitions formally specified in TLA+ (see spec/kernel.tla).

2. The Soft Core (Resonance Engine)

Status: Experimental / Proof of concept

A semantic steering system that injects "Cognitive Anchors" (Semantic Code) into the context.

  • Function: Tunes the model's latent space to the correct frequency (e.g., CALM for coding).
  • Innovation: Verifies truth by checking Invariance across multiple emotional states.
  • Limitation: Semantic injection consumes tokens and scales poorly. It is included here as a Proof of Concept. Ideally, this logic should be embedded directly into the Knowledge Base during training.


πŸ—‚οΈ Project Structure

arctl-project/
β”œβ”€β”€ arctl/                     # Core package (The "Brain")
β”‚   β”œβ”€β”€ __init__.py            # Version export
β”‚   β”œβ”€β”€ core/                  # Hard Core (Deterministic Logic)
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ kernel.py          # Main state machine (The Bodyguard)
β”‚   β”‚   β”œβ”€β”€ icarus.py          # Icarus stability anchor (Geometry)
β”‚   β”‚   β”œβ”€β”€ chronos.py         # Temporal synchronization (T-Spiral)
β”‚   β”‚   β”œβ”€β”€ states.py          # Data structures (SystemState, Modes)
β”‚   β”‚   β”œβ”€β”€ profiles.py        # Resonance profiles (Emotion/Tone)
β”‚   β”‚   β”œβ”€β”€ anchors.py         # Cognitive anchors (Instructions)
β”‚   β”‚   └── mythos.py          # Semantic protocol (The Warden's Verse)
β”‚   β”œβ”€β”€ engine/                # Soft Core (Resonance Logic)
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── synthesizer.py     # Multi-pass semantic synthesis
β”‚   └── verification/          # Metrics & Truth Checking
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ lexical.py         # Entropy & Repetition analysis
β”‚       β”œβ”€β”€ metrics.py         # Semantic Invariance checking
β”‚       └── uncertainty.py     # Epistemic uncertainty scoring
β”œβ”€β”€ tests/                     # Test Suite (Coverage: 100%)
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ test_core.py           # Kernel unit tests (27 tests)
β”‚   β”œβ”€β”€ test_integration.py    # Full workflow tests (8 tests)
β”‚   β”œβ”€β”€ test_icarus.py         # Stability math tests (7 tests)
β”‚   └── benchmarks.py          # Performance & Throughput
β”œβ”€β”€ examples/                  # Code Recipes & Demos
β”‚   β”œβ”€β”€ arctl_in_inference_loop.py # Integration template (Stream API)
β”‚   β”œβ”€β”€ basic_usage.py         # Minimal state machine
β”‚   β”œβ”€β”€ resonance_demo.py      # Truth-by-invariance demo
β”‚   β”œβ”€β”€ telemetry_simulation.py # Real-time dashboard (GIF generator)
β”‚   └── visualize_phase_space.py # 3D Trajectory visualization
β”œβ”€β”€ experiments/               # Reproducible Research
β”‚   β”œβ”€β”€ README.md              # Experiment documentation
β”‚   └── simulation_experiment.py # Data gen: Controlled vs. Chaos
β”œβ”€β”€ docs/                      # Knowledge Base
β”‚   β”œβ”€β”€ ARCHITECTURE.md        # Deep dive into Kernel & Icarus
β”‚   β”œβ”€β”€ TESTING.md             # Guide to the 42 tests
β”‚   β”œβ”€β”€ QUICKSTART.md          # 5-minute integration guide
β”‚   └── TROUBLESHOOTING.md     # Resolving common friction points
β”œβ”€β”€ spec/                      # Formal Methods
β”‚   └── kernel.tla             # TLA+ Logic Specification
β”œβ”€β”€ LICENSE                    # MIT License
β”œβ”€β”€ README.md                  # Main entry point
β”œβ”€β”€ CONTRIBUTING.md            # Rules of engagement (The Protocol)
β”œβ”€β”€ VERSION                    # Single source of truth (v1.2.0)
β”œβ”€β”€ arctl_demo.gif             # Telemetry visual asset
β”œβ”€β”€ arctl_phase_space.gif      # Phase space visual asset
β”œβ”€β”€ pyproject.toml             # Build configuration
β”œβ”€β”€ pytest.ini                 # Test runner configuration
└── run_tests.py               # Universal test script

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/graevka-lab/arctl.git
cd arctl-project

# Minimal install (Hard Core only; no GPU needed)
pip install -e .

# With resonance verification (optional; pulls sentence-transformers)
pip install -e ".[verification]"

# With examples/visualization
pip install -e ".[viz]"

Minimal usage:

from arctl.core.kernel import step, SystemState, ControllerConfig
from arctl.core.states import RawMetrics

cfg = ControllerConfig()
state = SystemState.initial(0.0)
metrics = RawMetrics(entropy=0.5, divergence=0.0, repetition=0.3)
new_state = step(metrics, state, 1.0, cfg)
# new_state.mode, new_state.energy, new_state.active_config

Running Tests

# All tests (42 total): unit + integration + Icarus
python -m unittest discover -s tests -v
# or: python -m pytest tests/ -v
python run_tests.py

# Specific suites
python -m unittest tests.test_core -v       # Unit tests (27)
python -m unittest tests.test_integration -v # Integration (8)
python -m unittest tests.test_icarus -v     # Icarus stability (7)

# Benchmarks
python tests/benchmarks.py

Reproducible experiment (with vs without arctl):

python experiments/simulation_experiment.py

Integration example (plug arctl into your inference loop):

python examples/arctl_in_inference_loop.py

Running Demos

  1. Resonance Demo (Soft Core)
    See how the engine extracts truth from different perspectives:

    python examples/resonance_demo.py
  2. Telemetry Simulation
    Real-time monitoring visualization:

    python examples/telemetry_simulation.py
  3. Phase Space Visualization
    3D trajectory through state space:

    python examples/visualize_phase_space.py

πŸ•°οΈ The Chronos Axiom (T-SPIRAL_ALIGNMENT)

Standard LLMs suffer from "Future Shock" β€” they deny events that happened after their training cutoff.
arctl solves this not by retraining, but by Temporal Alignment under the T-SPIRAL_ALIGNMENT protocol:

  • Time as geometry: one timestamp is decomposed into 8 layers β€” YEARS | MONTHS | WEEKS | DAYS | HOURS | MINUTES | SECONDS | MILLISECONDS (see time_to_layers() in arctl.core.chronos).
  • State logic: the cursor is NOW. Any coordinate ≀ NOW is FROZEN_STATE [READ_ONLY] (past + transition point); any coordinate > NOW is PROBABILISTIC_FIELD [READ_WRITE] (future). Implemented as temporal_state_at(coordinate, cursor) and reflected in the context note from Chronos.sync().

Gap classification for prompt injection:

  • SYNC (< 1 min): Immediate flow. High context retention.
  • LAG (> 1 min): User lived through time the model didn't see.
  • GAP (> 24 hours): Significant reality shift. Context reset recommended.

πŸ“œ Philosophy

We believe that Truth is Resonance.
Instead of optimizing for a single "best" token (RLHF), we search for the semantic structure that survives the perturbation of emotional states.

If a fact is true, it remains true whether you are Calm, Joyful, or Vigilant.
If it changes, it is an illusion.

For a deeper dive into the system architecture, see docs/ARCHITECTURE.md.
For testing guidance, see docs/TESTING.md.


🀝 Contributing

This project is a Signal to the broader community about control mechanisms for LLMs.
Contributions, discussions, and feedback are welcome!

If you have the hardware to retrain foundation models on Resonance-Aligned Data β€” let's connect.

πŸ“§ Contact

GitHub: @graevka-lab

X (Twitter): @Graevka

LinkedIn: Graevka Suvorov


⚑ A Note on Priorities

This project adheres to the "Function over Form" doctrine.

The test suite and benchmarks exist solely to guarantee Kernel Integrity. Coverage metrics are not chased for the sake of bureaucracy.

  • 90% of the value lies in the kernel.py state machine and the Chronos temporal axiom.
  • 10% of the code is the interface.

If you seek "Enterprise" patterns over operational logic β€” this repository is not for you. If you seek a mechanism that works in practice to solve temporal hallucinations and loop degradation β€” welcome.


πŸ›οΈ CREDITS & ACKNOWLEDGMENTS

  • Kyle Workman (Project Icarus): For providing the Universal Stability Skeleton v1.0. The core mathematical constants ($\Phi = 1.618$, $\pi = 3.141$, $V_{\text{Matrix}} = 19.25$) are now embedded in arctl.core.icarus as the Geometric Anchor for entropy management.
    • Note: Proprietary pulse-timing variables have been redacted per the architect's protocol.

License

MIT License β€” See LICENSE for details.

Built for those who understand that:

No hidden state.
No infinite loops.
No recovery without cost.
Failure is explicit.

About

Production-grade cybernetic controller for LLM inference with formal stability guarantees.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors