BLUX-cA – Clarity Agent

BLUX Logo

License Python Stars

Conscious, Constitutional, Multi-Model, and Fully Audited

BLUX-cA is the Conscious Agent kernel of the BLUX ecosystem β€” a constitution-driven, multi-agent reasoning engine designed to provide aligned guidance, orchestrated tooling, secure code execution, self-reflection, and verifiable intelligence.

It is the center of gravity for BLUX-Lite (orchestrator), BLUX-Quantum (CLI operations), BLUX-Guard (security cockpit), the Doctrine (ethical spine), and your future daughter-safe autonomy model.


🧠 Adapter Training Loop

The end-to-end adapter training, validation, and evaluation workflow lives in train/README.md. The BLUX-cA dataset is a separate repository and must be provided via DATASET_DIR (for example /workspace/blux-ca-dataset).

Run evaluation probes

python ca.py eval --dataset-dir /workspace/blux-ca-dataset --suite doctrine
python ca.py eval --dataset-dir /workspace/blux-ca-dataset --suite all

Reports are written to runs/eval_<timestamp>.md with PASS/FAIL per probe and doctrine boundaries.


🌟 Philosophy

BLUX-cA operates on three foundational principles:

  • Light > Denial – Confronting reality with compassion
  • Integrity > Approval – Truth-aligned responses over convenience
  • Truth > Comfort – Honest guidance that serves growth

All while keeping data local, audit trails immutable, and user sovereignty non-negotiable.


⚑ Core Capabilities

1. Adaptive Memory & Constitutional Learning

A privacy-first, consent-only memory system featuring:

  • Weighted Reinforcement Memory – Learns from interaction patterns
  • Memory Decay – Outdated information naturally fades
  • Consent-Gated Persistence – User control over data retention
  • Router-Bound Context Assembly – Intelligent context management
  • Reflective Distillation – Summaries and filtered insights
  • Hash-Chained Audit Logs – Append-only, tamper-evident records

Memory lives locally on the user's device β€” never externally.


2. The Conscious Heart

blux_ca.core.heart.ConsciousHeart orchestrates the core reasoning loop:

Processing Pipeline:

Perception β†’ Discernment β†’ Constitutional Check β†’ Verdict β†’ Response
                                    ↓
                          Reflection & Audit

Features:

  • Truth-alignment checks (integrity, awareness, compassion)
  • Koan-based self-reflection prompts
  • Case classification (struggler vs. indulger logic)
  • Doctrine-bound action selection
  • Direct integration with Clarity Engine

3. Multi-Agent Collaboration

BLUX-cA coordinates intelligently across model agents:

  • Task Broadcasting – Distribute work efficiently
  • Split/Merge Outputs – Parallel processing with synthesis
  • Conflict Resolution – Consensus-building heuristics
  • Router-Guided Delegation – Model selection optimization
  • Configurable Fan-Out – Scale for complex reasoning tasks

4. Advanced Code Intelligence

Integrated evaluator suite for real code reasoning:

Evaluators:

  • Python evaluator (safe-mode execution)
  • Node-based JavaScript/TypeScript evaluator
  • Bash subprocess evaluator
  • Async evaluators for concurrent operations
  • Multi-step pipeline evaluators

Code Context Layer:

  • Repository scanning and indexing
  • Line-range extraction with precision
  • Anchor detection (# >>> NAME)
  • Unified diff generation (diff-only workflow)
  • Patch validation (prevents anchor deletion)

Powers:

  • Intelligent bug finding
  • Context-aware code explanation
  • File-aware reasoning
  • Minimal diffs for orchestrator integration

5. Secure Orchestrator Layer

Located in ca/orchestrator/secure/:

  • Token-Based Authentication – Secure API access
  • Role-Based Authorization – Granular permission control
  • Multi-User Isolation – Secure concurrent operations
  • Tamper-Evident Audit Logs – Complete action history
  • Controlled Evaluator Sandboxing – Safe code execution

6. Real-Time Monitoring

Comprehensive observability system:

  • Threaded Agent Observer – Non-blocking performance tracking
  • Evaluator Performance Metrics – Execution profiling
  • Execution Trails – Complete operation history
  • Optional Web Dashboard – Visual monitoring interface
  • Automated Controller Insights – Machine-readable telemetry

7. CLI & Script Utilities

Main Entry Point: ca.py

Available Commands:

ca reflect           # Philosophical reasoning on a query
ca explain           # Explain code or concepts
ca code-eval         # Evaluate code for quality/security
ca code-task         # Execute code-related tasks
ca audit-export      # Export audit logs for review
ca repl              # Interactive REPL mode
ca doctrine          # Query doctrine engine
ca memory            # Memory management operations
ca router            # Router configuration and testing
ca self-test         # Run system diagnostics

Integration: Works seamlessly with bq (BLUX Quantum) for cross-shell automation.


8. Comprehensive Testing

Located under tests/:

  • Evaluator stress tests
  • Sandbox validation
  • Orchestrator load tests
  • Constitution scenario checks
  • CI-ready test suite with GitHub Actions

9. Optional Intelligence Stack

Activate extended reasoning capabilities:

  • Strategy/Tactic Selectors – Adaptive approach selection
  • Meta-Cognition Pass – Self-awareness in reasoning
  • Self-Critique – Reflective rewriting and improvement
  • Predictive User Modeling – Anticipate user needs
  • Multi-Agent Consensus – Collaborative decision resolution

Always constrained by:

  • The BLUX Constitution
  • Integrity > Approval
  • Truth > Comfort
  • Light > Denial

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/Outer-Void/blux-ca.git
cd blux-ca

# Install dependencies
pip install -r requirements.txt

# Verify installation
python ca.py --version

Basic Usage

CLI Examples:

# Philosophical reflection
python ca.py reflect "I feel lost today"

# Interactive REPL
python ca.py repl

# Evaluate code
python ca.py code-eval --file utils.py

# Batch processing
python ca.py --batch tasks.txt

# Export audit logs
python ca.py audit-export

Python API:

from blux_ca.core.heart import ConsciousHeart
from blux_ca.core.clarity_engine import ClarityEngine

# Initialize the conscious agent
engine = ClarityEngine()
heart = ConsciousHeart(engine)

# Process a request with constitutional guidance
result = heart.process(
    "I feel lost and need guidance.",
    user_type="struggler"
)

print(result.message)

πŸŽ› Training (QLoRA)

BLUX-cA ships with a QLoRA training pipeline under train/ for adapter-only finetuning against an external dataset repository. Provide the dataset path via --dataset-dir or DATASET_DIR.

# Validate dataset
python train/validate_dataset.py --dataset-dir /path/to/blux-ca-dataset --strict

# Optional dry-run (tokenize a few samples)
python train/train_qlora.py --dataset-dir /path/to/blux-ca-dataset --dry-run

# Train adapter
python train/train_qlora.py --dataset-dir /path/to/blux-ca-dataset

# Evaluate probes
python train/run_eval.py --dataset-dir /path/to/blux-ca-dataset --run runs/<timestamp> --strict

# Or via CLI
blux-ca train validate --dataset-dir /path/to/blux-ca-dataset --strict
blux-ca train qlora --dataset-dir /path/to/blux-ca-dataset --dry-run
blux-ca train qlora --dataset-dir /path/to/blux-ca-dataset
blux-ca train eval --dataset-dir /path/to/blux-ca-dataset --run runs/<timestamp> --strict

See train/README.md for prerequisites, configuration, and the release checklist. Training outputs are written to runs/<timestamp>/ (gitignored).


πŸ“‚ Project Structure

blux-ca/
β”œβ”€β”€ CLARITY_AGENT_SPEC.md      # Detailed specification
β”œβ”€β”€ LICENSE                     # Dual-license overview
β”œβ”€β”€ LICENSE-APACHE              # Apache 2.0 terms
β”œβ”€β”€ LICENSE-COMMERCIAL          # Commercial terms
β”œβ”€β”€ NOTICE                      # Apache notice
β”œβ”€β”€ COMMERCIAL.md               # Commercial licensing guide
β”œβ”€β”€ README.md                   # This file
β”œβ”€β”€ ca.py                       # Main CLI entry point
β”œβ”€β”€ pyproject.toml             # Python project metadata
β”œβ”€β”€ requirements.txt           # Dependencies
β”œβ”€β”€ mkdocs.yml                 # Documentation configuration
β”‚
β”œβ”€β”€ blux_ca/                   # Legacy/alternative namespace
β”‚   └── [Python modules]
β”‚
β”œβ”€β”€ ca/                        # Core agent implementation
β”‚   β”œβ”€β”€ adaptors/              # External system integrations
β”‚   β”‚   β”œβ”€β”€ bq_cli.py          # BLUX Quantum CLI integration
β”‚   β”‚   β”œβ”€β”€ doctrine.py        # Doctrine engine adapter
β”‚   β”‚   β”œβ”€β”€ guard.py           # BLUX-Guard security hooks
β”‚   β”‚   β”œβ”€β”€ lite.py            # BLUX-Lite orchestrator
β”‚   β”‚   └── quantum.py         # Quantum CLI tooling
β”‚   β”‚
β”‚   β”œβ”€β”€ agent/                 # Agent logic and reasoning
β”‚   β”‚   β”œβ”€β”€ advanced/          # Advanced features
β”‚   β”‚   β”‚   β”œβ”€β”€ adaptive_memory.py
β”‚   β”‚   β”‚   β”œβ”€β”€ monitoring.py
β”‚   β”‚   β”‚   β”œβ”€β”€ multi_agent.py
β”‚   β”‚   β”‚   └── reasoning.py
β”‚   β”‚   β”œβ”€β”€ constitution.py    # Constitutional framework
β”‚   β”‚   β”œβ”€β”€ core_agent.py      # Base agent implementation
β”‚   β”‚   β”œβ”€β”€ discernment.py     # Decision-making logic
β”‚   β”‚   β”œβ”€β”€ memory.py          # Memory management
β”‚   β”‚   └── audit.py           # Audit logging
β”‚   β”‚
β”‚   β”œβ”€β”€ api/                   # API service layer
β”‚   β”‚   β”œβ”€β”€ schemas.py         # Data models
β”‚   β”‚   └── service.py         # FastAPI service
β”‚   β”‚
β”‚   β”œβ”€β”€ core/                  # Core engine components
β”‚   β”‚   β”œβ”€β”€ clarity_engine.py  # Main reasoning engine
β”‚   β”‚   β”œβ”€β”€ heart.py           # Conscious processing core
β”‚   β”‚   β”œβ”€β”€ code_context.py    # Code analysis layer
β”‚   β”‚   β”œβ”€β”€ code_tasks.py      # Code task execution
β”‚   β”‚   β”œβ”€β”€ diff_engine.py     # Diff generation
β”‚   β”‚   β”œβ”€β”€ compass/           # Intent detection
β”‚   β”‚   β”œβ”€β”€ perception.py      # Input processing
β”‚   β”‚   β”œβ”€β”€ discernment.py     # Judgment logic
β”‚   β”‚   β”œβ”€β”€ reflection.py      # Self-reflection
β”‚   β”‚   β”œβ”€β”€ constitution.py    # Constitutional checks
β”‚   β”‚   β”œβ”€β”€ intervention.py    # Intervention system
β”‚   β”‚   β”œβ”€β”€ koan.py            # Philosophical prompts
β”‚   β”‚   β”œβ”€β”€ dimensions.py      # Dimensional analysis
β”‚   β”‚   └── states.py          # State management
β”‚   β”‚
β”‚   β”œβ”€β”€ evaluator/             # Code evaluation engines
β”‚   β”‚   β”œβ”€β”€ python.py          # Python evaluator
β”‚   β”‚   β”œβ”€β”€ js_ts.py           # JavaScript/TypeScript
β”‚   β”‚   └── advanced/          # Async evaluators
β”‚   β”‚       β”œβ”€β”€ bash_evaluator.py
β”‚   β”‚       β”œβ”€β”€ js_ts_async.py
β”‚   β”‚       β”œβ”€β”€ python_async.py
β”‚   β”‚       └── pipeline.py
β”‚   β”‚
β”‚   β”œβ”€β”€ orchestrator/          # Multi-agent coordination
β”‚   β”‚   β”œβ”€β”€ router.py          # Task routing
β”‚   β”‚   β”œβ”€β”€ controller.py      # Orchestration controller
β”‚   β”‚   β”œβ”€β”€ registry.py        # Agent registry
β”‚   β”‚   β”œβ”€β”€ config.yaml        # Orchestrator config
β”‚   β”‚   └── secure/            # Security layer
β”‚   β”‚       β”œβ”€β”€ auth.py
β”‚   β”‚       β”œβ”€β”€ audit.py
β”‚   β”‚       └── secure_controller.py
β”‚   β”‚
β”‚   β”œβ”€β”€ cli.py                 # CLI implementation
β”‚   β”œβ”€β”€ config.py              # Configuration management
β”‚   └── telemetry.py           # Telemetry and monitoring
β”‚
β”œβ”€β”€ constitution/              # Constitutional definitions
β”‚   └── behavior.md
β”‚
β”œβ”€β”€ doctrine/                  # Policy and governance
β”‚   └── [Doctrine rules]
β”‚
β”œβ”€β”€ ethos/                     # Ethical framework
β”‚   └── manifest.yaml
β”‚
β”œβ”€β”€ identity/                  # Agent identity
β”‚   └── seed.json
β”‚
β”œβ”€β”€ docs/                      # Comprehensive documentation
β”‚   β”œβ”€β”€ ARCHITECTURE.md
β”‚   β”œβ”€β”€ CONFIGURATION.md
β”‚   β”œβ”€β”€ CONSTITUTION.md
β”‚   β”œβ”€β”€ DISCERNMENT.md
β”‚   β”œβ”€β”€ ETHICS_ENGINE.md
β”‚   β”œβ”€β”€ INSTALL.md
β”‚   β”œβ”€β”€ INTEGRATIONS.md
β”‚   β”œβ”€β”€ INTERVENTIONS.md
β”‚   β”œβ”€β”€ OPERATIONS.md
β”‚   β”œβ”€β”€ PRIVACY.md
β”‚   β”œβ”€β”€ ROADMAP.md
β”‚   β”œβ”€β”€ SECURITY.md
β”‚   β”œβ”€β”€ TROUBLESHOOTING.md
β”‚   └── VISION.md
β”‚
β”œβ”€β”€ scripts/                   # Utility scripts
β”‚   β”œβ”€β”€ batch_task.py
β”‚   β”œβ”€β”€ export_audit_json.py
β”‚   β”œβ”€β”€ gen_filetree.py
β”‚   β”œβ”€β”€ ingest_reflection.py
β”‚   β”œβ”€β”€ interactive_repl.py
β”‚   β”œβ”€β”€ memory_query.py
β”‚   β”œβ”€β”€ reflection.py
β”‚   └── validate_constitution.py
β”‚
└── tests/                     # Test suite
    β”œβ”€β”€ ca/                    # Component tests
    β”‚   β”œβ”€β”€ test_audit.py
    β”‚   β”œβ”€β”€ test_constitution.py
    β”‚   β”œβ”€β”€ test_discernment.py
    β”‚   β”œβ”€β”€ test_heart.py
    β”‚   └── test_memory.py
    β”œβ”€β”€ fixtures/              # Test fixtures
    β”œβ”€β”€ test_agent.py
    β”œβ”€β”€ test_evaluator.py
    β”œβ”€β”€ test_orchestrator.py
    β”œβ”€β”€ test_security.py
    └── test_integration.py

πŸ§ͺ Testing & Quality

Run the comprehensive test suite:

# Run all tests
pytest

# Run specific test categories
pytest tests/ca/                    # Component tests
pytest tests/test_evaluator.py     # Evaluator tests
pytest tests/test_orchestrator.py  # Orchestration tests
pytest tests/test_security.py      # Security tests

# Run with coverage reporting
pytest --cov=ca --cov-report=html

# Run stress tests
pytest tests/test_stress.py -v

Developer quality gates:

make lint   # compileall + ruff + black --check
make fmt    # apply black and autofix ruff suggestions
make smoke  # CLI smoke checks (help + doctor + train help)

CI/CD: GitHub Actions workflows automatically run tests on all pull requests.


πŸ”§ Configuration

BLUX-cA uses hierarchical configuration:

  1. Built-in defaults – Sensible out-of-the-box settings
  2. Environment variables – Runtime overrides
  3. Local config files – User-specific customization

Example Configuration:

# config.yaml
orchestrator:
  max_agents: 5
  timeout: 30s
  conflict_resolution: consensus
  
memory:
  decay_rate: 0.1
  reinforcement_factor: 1.5
  consent_required: true
  
security:
  audit_enabled: true
  sandbox_mode: strict
  auth_required: true
  
evaluator:
  python_timeout: 10s
  js_timeout: 5s
  max_memory: 512MB

See docs/CONFIGURATION.md for complete options.


πŸ“š Documentation

Comprehensive documentation is available:

Document Description
ARCHITECTURE.md System architecture and design
INSTALL.md Installation and setup guide
CONFIGURATION.md Configuration reference
CONSTITUTION.md Constitutional framework
SECURITY.md Security model and practices
PRIVACY.md Privacy guarantees and data handling
INTEGRATIONS.md Integration with BLUX ecosystem
OPERATIONS.md Operations and deployment
TROUBLESHOOTING.md Common issues and solutions
ROADMAP.md Future development plans

πŸ›οΈ Enterprise Features

The enterprise subsystem provides production-ready capabilities:

  • FastAPI Service (blux_ca.api.service) – RESTful API interface
  • Doctrine Integration – Policy-driven governance layer
  • BLUX-Guard Hooks – Real-time security monitoring
  • BLUX-Lite Adapter – Orchestration planning and execution
  • BLUX-Quantum CLI – Advanced command-line operations
  • MkDocs Site – Hosted documentation portal

Doctrine Engine

Constitutional policy engine with rule bundles:

# Check text against doctrine
python -m doctrine.cli check "text to analyze"

Located in doctrine/rules/ with extensible rule system.

Clarity Agent Runtime

New runtime orchestrator under ca/runtime/ integrates:

  • Doctrine Governance – Policy enforcement
  • Lite Planning – Task orchestration
  • Guard Labeling – Security classification
  • Pluggable LLM Stubs – Model abstraction
  • Safety Overrides – Crisis-aware response system
  • Recovery Helpers – Graceful error handling

🀝 Contributing

We welcome contributions aligned with the BLUX Constitution:

Core Principles

  • Integrity > Approval – Honest feedback and truthful code
  • Truth > Comfort – Solutions over convenient shortcuts
  • Light > Denial – Transparency in all changes

Contribution Process

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Write tests for your changes
  4. Ensure all tests pass (pytest)
  5. Update documentation as needed
  6. Commit with clear messages (git commit -m 'Add amazing feature')
  7. Push to your branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

Requirements

  • βœ… Unit tests for all new functionality
  • βœ… Constitutional alignment verification
  • βœ… Clear, comprehensive documentation
  • βœ… No breaking changes to audit logs or security features
  • βœ… Code follows project style guidelines

πŸ—ΊοΈ Roadmap

Near Term

  • Enhanced multi-model support (GPT-4, Claude, Gemini)
  • Visual dashboard for real-time monitoring
  • Extended sandboxing with container isolation
  • Plugin architecture for custom evaluators

Medium Term

  • Distributed orchestration capabilities
  • Advanced memory compression and retrieval
  • Federated learning support
  • Enhanced mobile/edge deployment

Long Term

  • Autonomous agent swarms
  • Cross-platform memory sync
  • Blockchain-backed audit trails
  • Quantum-resistant security

See docs/ROADMAP.md for detailed timeline and priorities.


πŸ”’ Security

BLUX-cA prioritizes security at every layer:

  • Sandboxed Execution – Isolated environments for code evaluation
  • Immutable Audit Logs – Hash-chained, tamper-evident records
  • Token-Based Authentication – Secure API access control
  • Role-Based Authorization – Granular permission management
  • Data Encryption – At-rest and in-transit protection
  • Vulnerability Scanning – Continuous security monitoring
  • Multi-User Isolation – Secure concurrent operations

Reporting Security Issues

Please report security vulnerabilities responsibly:

πŸ“§ Email: outervoid.blux@gmail.com

Please include:

  • Description of the vulnerability
  • Steps to reproduce
  • Potential impact assessment
  • Suggested fix (if available)

We take security seriously and will respond promptly to all reports.


πŸ“œ License

BLUX-cA is dual-licensed:

  • Open Source (Apache 2.0): You may use, modify, and distribute the project under the terms in LICENSE-APACHE. Keep notices intact and document your changes.
  • Commercial License: For embedding in commercial products, offering hosted services, or other business uses beyond Apache 2.0, a commercial agreement is required. See LICENSE-COMMERCIAL or contact theoutervoid@outlook.com to obtain terms.

See LICENSE for an overview of the dual-license options.

Apache 2.0 highlights:

  • βœ… Use, modify, and distribute with notice retention
  • βœ… Patent license from contributors
  • ⚠️ Include license and NOTICE when redistributing
  • ⚠️ Document file modifications

Commercial path highlights:

  • βœ… Commercial use available under a separate agreement
  • ⚠️ No redistribution or sublicensing without commercial terms
  • πŸ“§ Contact: theoutervoid@outlook.com

🌐 Links & Resources

Related Projects

  • BLUX-Lite – Task orchestration layer
  • BLUX-Quantum – CLI operations framework
  • BLUX-Guard – Security cockpit and monitoring

πŸ™ Acknowledgments

Built with the principles of conscious AI development:

  • πŸ”’ Privacy-First Design – Local data, user sovereignty
  • 🧭 Ethical Reasoning – Constitutional alignment
  • πŸ” Verifiable Intelligence – Auditable decision-making
  • 🀝 Human Collaboration – AI as partner, not replacement
  • 🌟 Continuous Growth – Self-reflection and improvement

BLUX-cA – Where Consciousness Meets Code

Made with ❀️ by Outer Void

Light > Denial β€’ Integrity > Approval β€’ Truth > Comfort

Stars Follow

🧠 QLoRA Training

A reproducible QLoRA adapter pipeline lives under train/. It expects an external dataset repository with data/*.jsonl and eval/*.jsonl files using the BLUX-cA chat schema. Follow the commands in train/README.md to validate datasets, run dry-runs, train adapters, and evaluate probes before sharing adapters (base weights not included).

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for Outer-Void/blux-ca

Base model

Qwen/Qwen2.5-7B
Finetuned
(2275)
this model