Skip to main content

CODITECT Mixture of Experts (MoE) System Analysis

CODITECT Mixture of Experts (MoE) System Analysis

Generated: December 31, 2025 Analysis Type: Comprehensive MoE System Review Certainty: HIGH (95%) - Based on direct codebase inspection


Executive Summary

CODITECT implements a sophisticated Mixture of Experts (MoE) architecture for multi-agent orchestration, quality evaluation, and document classification. The system leverages ensemble intelligence through parallel agent execution, weighted consensus calculation, and judge-based validation.

Key Metrics

MetricValueSource
Core MoE Commands5/moe-agents, /moe-judges, /moe-workflow, /moe-analyze, /moe-judge
MoE ADRs2ADR-008 (Analysis), ADR-009 (Judges)
Python Implementation Files23scripts/moe_classifier/
Analyst Types5structural, content, metadata, semantic, pattern
Judge Types3consistency, quality, domain
Type Experts7guide, reference, workflow, agent, command, ADR, skill

Skill Capabilities

  • Pattern Recognition: Identify applicable patterns
  • Automation: Automate repetitive tasks
  • Quality: Ensure consistent results

Skill Capabilities

  • Pattern Recognition: Identify applicable patterns
  • Automation: Automate repetitive tasks
  • Quality: Ensure consistent results

Skill Capabilities

  • Pattern Recognition: Identify applicable patterns
  • Automation: Automate repetitive tasks
  • Quality: Ensure consistent results

Skill Capabilities

  • Pattern Recognition: Identify applicable patterns
  • Automation: Automate repetitive tasks
  • Quality: Ensure consistent results

Skill Capabilities

  • Pattern Recognition: Identify applicable patterns
  • Automation: Automate repetitive tasks
  • Quality: Ensure consistent results

System Architecture

Three-Layer MoE Model

┌─────────────────────────────────────────────────────────────────────┐
│ LAYER 1: EXPERT ASSEMBLY │
│ /moe-agents │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Expert │ │ Expert │ │ Expert │ │ Expert │ │ Expert │ │
│ │ A │ │ B │ │ C │ │ D │ │ E │ │
│ │(Domain) │ │(Domain) │ │(Domain) │ │(Domain) │ │(Domain) │ │
│ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │
│ │ │ │ │ │ │
│ └──────────┴────┬─────┴──────────┴──────────┘ │
│ ▼ │
├─────────────────────────────────────────────────────────────────────┤
│ LAYER 2: JUDGE EVALUATION │
│ /moe-judges │
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │
│ │ Consistency │ │ Quality │ │ Domain │ │
│ │ Judge │ │ Judge │ │ Judge │ │
│ │ (Cross-ref) │ │ (Vote quality)│ │ (CODITECT rules) │
│ └───────┬───────┘ └───────┬───────┘ └───────┬───────┘ │
│ │ │ │ │
│ └─────────────────┼─────────────────┘ │
│ ▼ │
├─────────────────────────────────────────────────────────────────────┤
│ LAYER 3: CONSENSUS & OUTPUT │
│ /moe-workflow │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Weighted Consensus + Quality Gate + Final Verdict │ │
│ └─────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────┘

Command Reference

1. /moe-agents - Expert Assembly

Purpose: Analyzes a use case and assembles an optimal team of specialized agents.

Algorithm:

  1. Break down task into component requirements
  2. Map requirements to agent specializations
  3. Select 3-7 agents with complementary skills
  4. Assign specific tasks to each expert
  5. Create coordination plan for collaboration

Example Use Cases:

TaskExpert Team
Build SaaS Productsenior-architect, backend-architect, frontend-react-typescript-expert, devops-engineer, security-specialist
Competitive Analysiscompetitive-market-analyst, market-researcher, business-intelligence-analyst, web-search-researcher
Security Auditsecurity-specialist, penetration-testing-agent, backend-api-security, compliance-checker-agent

Invocation:

/moe-agents build complete authentication system with OAuth2

2. /moe-judges - Judge Panel Evaluation

Purpose: Assembles a panel of specialized judges to evaluate, critique, and score output.

Evaluation Dimensions:

DimensionWeightScore Range
Architecture Quality25%1-10
Security Posture25%1-10
Code Quality20%1-10
Test Coverage15%1-10
Documentation15%1-10

Verdict Categories:

ScoreVerdictMeaning
9-10EXCELLENTProduction ready, exceeds standards
7-8APPROVEDReady with minor improvements
5-6CONDITIONALNeeds improvements before approval
3-4REVISION REQUIREDSignificant issues
1-2REJECTEDDoes not meet minimum standards

Invocation:

/moe-judges evaluate API design for production readiness

3. /moe-workflow - Complete Expert→Judge Pipeline

Purpose: Full lifecycle: experts create → judges evaluate → iterate to quality.

7-Phase Workflow:

PhaseActivityOutput
1. AnalyzeUnderstand requirements, define criteriaRequirements doc
2. AssembleSelect 3-7 domain expertsExpert team roster
3. ExecuteExperts collaborate on deliverableInitial output
4. Judge SetupSelect 3-5 evaluation expertsJudge panel
5. EvaluateEach judge reviews independentlyScores + feedback
6. IterateAddress feedback until passingRefined output
7. DeliverQuality-assured outputFinal deliverable

Quality Gates:

GateRequirements
GoldAll scores 9+/10 → Ship immediately
SilverAll scores 8+/10 → Ship with monitoring
BronzeAll scores 7+/10 → Ship with caveats
FailAny score <7/10 → Iterate

4. /moe-analyze - Research with Certainty Scoring

Purpose: Multi-agent research with explicit certainty quantification.

Certainty Scoring Formula:

certainty_score = (
evidence_support * 0.40 + # Quality of supporting sources
source_reliability * 0.25 + # Credibility of sources
internal_consistency * 0.20 + # Agent agreement level
recency * 0.15 # Information freshness
)

Certainty Levels:

ScoreLevelAction
85-100%HIGHReport with confidence
60-84%MEDIUMNote limitations, provide sources
30-59%LOWExplicitly state uncertainty
0-29%INFERREDRequire logical inference chain

Implementation Details

Python MoE Classifier (scripts/moe_classifier/)

The production implementation provides document classification with:

Components:

  • core/orchestrator.py - MoEOrchestrator class (416 lines)
  • core/consensus.py - ConsensusCalculator with weighted voting (245 lines)
  • core/models.py - Data structures (Document, AnalystVote, ConsensusResult)
  • judges/base.py - BaseJudge abstract class (134 lines)
  • analysts/ - 5 analyst implementations

Orchestrator Configuration:

@dataclass
class OrchestratorConfig:
max_parallel_analysts: int = 5
max_parallel_judges: int = 3
analyst_timeout_seconds: float = 30.0
judge_timeout_seconds: float = 10.0
enable_deep_analysis: bool = True

Approval Types:

class ApprovalType(Enum):
AUTO_APPROVED = "auto" # ≥85% confidence, ≥80% agreement
JUDGE_APPROVED = "judge" # 2/3 judges approve
DEEP_ANALYSIS_APPROVED = "deep" # Deep analysts resolved
HUMAN_REVIEW_REQUIRED = "human" # Needs human review
ESCALATED = "escalated" # Failed all approval paths
PENDING = "pending" # Awaiting judgment

Consensus Algorithm

From moe-consensus-algorithm.md:

# Thresholds
AUTO_APPROVAL_CONFIDENCE = 0.90 # Skip judges if above
JUDGE_APPROVAL_CONFIDENCE = 0.85 # Accept with judge approval
AGREEMENT_THRESHOLD = 0.60 # Minimum 3/5 analysts agree

# Decision Flow
if confidence >= 0.90:
→ AUTO_APPROVED

elif agreement >= 0.60 and confidence >= 0.85:
→ Invoke 3 judges
→ If 2/3 approve: JUDGE_APPROVED
→ If any veto: ESCALATED

else:
→ ESCALATED (human review)

Optimal Use Cases

When to Use Each Command

Use CaseCommandWhy
Complex multi-step task/moe-workflowEnd-to-end expert coordination + quality gates
Need team assembly/moe-agentsIntelligent agent selection based on requirements
Evaluate existing output/moe-judgesMulti-perspective quality scoring
Research with citations/moe-analyzeCertainty-quantified research with source tracking
Document classification/classifyAutomated MoE document typing

Usage Patterns

Pattern 1: Full-Stack Feature Development

# Step 1: Assemble expert team
/moe-agents build user authentication with OAuth2, JWT, and MFA

# Step 2: Execute with coordination
/agent orchestrator "Coordinate authentication feature..."

# Step 3: Evaluate output
/moe-judges evaluate authentication system for production

# OR use combined workflow
/moe-workflow implement and validate user authentication system

Pattern 2: Research with Validation

# Research with certainty scoring
/moe-analyze --with-search "Enterprise DMS market standards 2024-2025"

# Then judge the research quality
/moe-judges evaluate research findings for accuracy and completeness

Pattern 3: Iterative Quality Improvement

# Initial implementation
/moe-agents build REST API for user management

# First evaluation
/moe-judges evaluate API design (score: 6.5/10)

# Iterate based on feedback
/moe-workflow iterate API design to 8+/10 quality

Agent Roles in MoE

Analyst Agents (Parallel Execution)

AnalystFocusInputOutput
structuralFile structure, pathsFile path analysisType + confidence
contentDocument contentText analysisType + confidence
metadataYAML frontmatterMetadata parsingType + confidence
semanticDeep meaningLLM analysisType + confidence
patternRegex patternsPattern matchingType + confidence

Judge Agents (Validation)

JudgeValidationVeto Authority
consistencyCross-reference with related docsYes
qualityVote distribution, outlier detectionYes
domainCODITECT-specific rulesYes

Type Expert Agents (Deep Analysis)

ExpertDocument TypeKey Signals
GuideExpertGuides/TutorialsSteps, prerequisites, troubleshooting
ReferenceExpertAPI/SpecsTables, schemas, configuration
WorkflowExpertProcessesPhases, diagrams, checklists
AgentExpertAI AgentsPersona, capabilities, tools
CommandExpertCommandsInvocation, parameters, usage
ADRExpertDecisionsContext, decision, consequences
SkillExpertPatternsWhen to use, patterns, I/O

Research Foundation

The MoE system is backed by peer-reviewed research (per ADR-008/009):

ResearchVenueContributionCertainty
Semantic DensityNeurIPS 2024Multi-factor confidence scoring96%
Self-Consistency (CoT-SC)ICLR 2022Internal consistency measurement97%
Mixture-of-AgentsarXiv 2024Ensemble wisdom (65.1% AlpacaEval)90%
UoT FrameworkNeurIPS 2024Explicit uncertainty modeling93%
Chain-of-VerificationACL 2024Evidence validation protocol92%
G-EvalEMNLP 2023Chain-of-thought evaluation95%
ChatEvalICLR 2024Multi-agent referee teams91%

Best Practices

1. Choose the Right Granularity

ComplexityCommandTeam Size
Simple task/which → single agent1
Moderate task/moe-agents3-4
Complex task/moe-workflow5-7
Enterprise task/moe-workflow + iteration7+

2. Leverage Parallel Execution

The orchestrator runs analysts in parallel:

with ThreadPoolExecutor(max_workers=5) as executor:
futures = [executor.submit(analyst.analyze, doc) for analyst in analysts]

Maximum parallelism: 5 analysts + 3 judges = 8 parallel agents

3. Use Quality Gates

GateWhen to Use
Gold (9+)Production deployments, security-critical
Silver (8+)Standard releases
Bronze (7+)Development, prototypes

4. Handle Escalations

When consensus fails:

  1. Deep Analysis automatically invoked
  2. Type Experts provide specialized analysis
  3. If still unclear → Human review required

Integration Points

With Orchestrator Agent

# MoE commands invoke orchestrator for coordination
/agent orchestrator "Coordinate MoE workflow for authentication feature..."

With Quality Specialists

# Judges include quality specialists
judges = [
"codi-qa-specialist", # Quality assurance
"code-reviewer", # Code quality
"architect-review", # Architecture
"security-specialist" # Security posture
]

With Documentation Writer

# After MoE workflow completes
/agent codi-documentation-writer "Document the API created by MoE workflow"

Performance Characteristics

MetricTargetNotes
Parallel Analysis<3s5 analysts concurrent
Consensus Calculation<10msIn-memory
Judge Validation<1sOnly for 85-90% confidence
Total Pipeline<5sEnd-to-end classification
Throughput100/minBatch processing mode
Approval Rate>85%Auto + Judge approved

Command Quick Reference

# Expert Assembly
/moe-agents <task-description>

# Judge Evaluation
/moe-judges <what-to-evaluate>

# Complete Workflow
/moe-workflow <task-description>

# Research with Certainty
/moe-analyze <research-question>

# Document Classification
/classify <path> -r --expert


Document Version: 1.0.0 Last Updated: December 31, 2025 Author: CODITECT Analysis System Certainty Level: HIGH (95%) - Direct codebase inspection