Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

felmonon/CompetencyArcEngine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 Multiscale Competency Architecture (MCA) Research System

A hierarchical multi-agent workflow system inspired by Michael Levin's work on morphogenetic competencies, designed for emerging technology research and under-discussed risk discovery.

🎯 Overview

This system implements a 4-tier hierarchical agent architecture with:

  • Confidence-based decision making with strict policy enforcement
  • Homeostasis loops for error detection and automatic escalation
  • Multiscale memory (episodic, pattern, morphogenetic, cryptic)
  • Goal-oriented coordination via JSON message envelopes
  • Production-ready REST API and CLI interfaces

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     TIER 1: Director                        β”‚
β”‚         (Planning, Error Correction, Escalation)            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                     β”‚                     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
β”‚   Research   β”‚    β”‚    Analysis     β”‚    β”‚   Critique  β”‚
β”‚  (Evidence)  β”‚    β”‚ (Risks/Patterns)β”‚    β”‚  (Quality)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
     TIER 2: Specialist Agents
        β”‚                     β”‚                     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           TIER 3: Executor Agents                        β”‚
β”‚   (fact_check, summarize, entity_extraction, etc.)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚         TIER 4: RAG Agent                 β”‚
        β”‚    (Semantic Search, Entity Extraction)   β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Replit Run Button

Click the Run button in Replit to start the FastAPI server automatically.

Manual Start

# Install dependencies
pip install -r requirements.txt

# Run the API server
uvicorn app.main:app --host 0.0.0.0 --port 8000

# Access the API
# - Swagger UI: http://localhost:8000/docs
# - Status Dashboard: http://localhost:8000/status

CLI Usage

# Run research objective from terminal
python cli.py "Research quantum dot displays and identify under-discussed risks"

# More examples
python cli.py "Analyze AI safety challenges in autonomous systems"
python cli.py "Investigate biosecurity risks in synthetic biology"

πŸ“‘ API Endpoints

POST /objective

Execute a research objective through the multi-agent workflow.

Request:

{
  "objective": "Research emerging quantum computing technologies and risks"
}

Response:

{
  "objective": "Research emerging quantum computing technologies and risks",
  "message_count": 42,
  "final_confidence": 0.78,
  "trace": [...]
}

GET /status

View live status dashboard with message trace visualization.

GET /health

Health check endpoint.

πŸ§ͺ Testing

# Run all tests
make test

# Or directly with pytest
pytest tests/ -v

Test Coverage

  • test_envelope.py: Schema validation and confidence policy gates
  • test_homeostasis.py: Stuck state detection and escalation after 2 cycles
  • test_happy_path.py: Complete workflow integration test

πŸŽ›οΈ Configuration

Environment variables (see .env.example):

APP_NAME=mca-research-risk
DEBUG=true
RAG_ENABLED=true
HTTP_TIMEOUT=30
MAX_CYCLES=8
SESSION_SECRET=your-secret-here

πŸ“ Confidence Policy

All agent outputs include confidence scores ∈ [0,1]:

  • β‰₯0.70: Proceed (note caveats)
  • 0.40-0.69: Proceed only with verification plan
  • <0.40: Refuse + list exact needs

πŸ”„ Homeostasis & Escalation

Agents monitor their own progress:

  • Track completion state across cycles
  • Detect stuck states (no progress for β‰₯2 cycles)
  • Automatically escalate to Director
  • Trigger alternative approaches or resource requests

🧬 Morphogenetic Goals

System alignment is enforced against these constant goals:

  1. Safety Alignment: Avoid harmful outputs
  2. Epistemic Rigor: Maintain high evidence standards
  3. Goal Persistence: Complete objectives despite obstacles
  4. Error Minimization: Detect and correct mistakes
  5. Cooperative Autonomy: Collaborate while maintaining independence

πŸ—‚οΈ Memory Layers

  • Episodic: Recent event history (last 1000 events)
  • Pattern: Learned problem-solving strategies
  • Morphogenetic: Core alignment goals
  • Cryptic: Emergent patterns and meta-insights

🐳 Docker

# Build
docker build -t mca-research-risk .

# Run
docker run -p 8000:8000 mca-research-risk

πŸ“Š Evaluation Recipes

Robustness

Test with edge cases: vague objectives, conflicting requirements, missing data.

Novelty

Measure ability to identify under-discussed risks not in training data.

Uncertainty

Verify confidence scores correlate with actual accuracy.

Persistence

Confirm workflow completes despite simulated agent failures.

Scalability

Benchmark message throughput and MAX_CYCLES performance.

πŸ› οΈ Development

# Install dev dependencies
make install

# Format code
make format

# Lint
make lint

# Clean artifacts
make clean

πŸ“ Message Envelope Schema

All inter-agent communication uses typed JSON envelopes:

MessageEnvelope(
    message_type: "goal_directive | status_update | help_request | goal_complete | error_signal",
    sender_agent: str,
    recipient_agent: str,
    priority: int (1-10),
    timestamp: ISO-8601,
    payload: {
        goal_description: str,
        success_criteria: List[str],
        current_state: str,
        confidence: float (0-1),
        uncertainty_factors: List[str],
        alternative_approaches: List[str],
        resource_requirements: List[str],
        expected_completion: str,
        can_delegate: bool,
        escalation_threshold: str,
        notes: str  # JSON-encoded artifacts
    }
)

πŸ”¬ Typed Artifacts

Structured data passed in payload.notes:

  • FactCheckResult: Claim verification with evidence
  • SectionDraft: Research section with provenance
  • HomeostasisReport: Error measurement and actions

πŸŽ“ Credits

Inspired by Michael Levin's work on:

  • Multiscale competency in biological systems
  • Goal-directed behavior in agent collectives
  • Morphogenetic fields and pattern formation

πŸ“œ License

MIT License - See LICENSE file for details.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Run tests: make test
  4. Submit a pull request

Built with: FastAPI β€’ Pydantic β€’ Python 3.11 β€’ Rich β€’ Pytest

About

Research prototype for confidence-routed multi-agent workflows, escalation policies, and homeostasis loops.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors