
AI Code Guard Agents
1 Single Node.js Command • Zero Python • Zero GPU • Zero Cloud • Runs in ~19ms AI Code Guard Agents (sovereign-moe-swarm v1.2) deploys a local Mixture-of-Experts (MoE) swarm of 5 independent micro-agent brains directly inside your repository. Every brain starts from scratch as a deterministic, Git-syncable JSON file and continuously learns from your codebase through Bidirectional Q-Learning — without ever sending a single line of code to external cloud APIs. #Produtividade #Engenharia #Educação
🧠 AI Code Guard Agents — 5 Self-Learning Local AI Security Brains
1 Single Node.js Command • Zero Python • Zero GPU • Zero Cloud • Runs in ~19ms
AI Code Guard Agents (sovereign-moe-swarm v1.2) deploys a local Mixture-of-Experts (MoE) swarm of 5 independent micro-agent brains directly inside your repository. Every brain starts from scratch as a deterministic, Git-syncable JSON file and continuously learns from your codebase through Bidirectional Q-Learning — without ever sending a single line of code to external cloud APIs.
⚡ Why Engineering Teams Use It
5 Independent Specialist Brains (
brains/*.json):- 💰 FinanceExpert — Blocks client-side price tampering, checkout arithmetic underflow/overflow, Stripe/PayPal webhook forgery, and Conservation Law (
Σ = 0) violations. - 🗄️ SqlDataExpert — Catches SQL/GraphQL injection, permissive Supabase RLS (
USING (true)), and mutable financial ledger operations (UPDATE/DELETE). - 🔐 AuthApiExpert — Detects IDOR privilege escalation, unverified
jwt.decode(), hardcoded secrets, and unprotected FastAPI/Express body fields. - 🧬 AstQualityExpert — Spots AST Trojans, hidden assignments in conditionals, infinite loops, high-entropy obfuscated payloads, and dependency typosquatting.
- ⛓️ EpisodicMemoryExpert — Seals every audit episode in an immutable SHA-256 hash chain to automatically flag REGRESSIONS whenever a previously fixed bug returns.
- 💰 FinanceExpert — Blocks client-side price tampering, checkout arithmetic underflow/overflow, Stripe/PayPal webhook forgery, and Conservation Law (
⚖️ Real Bidirectional Q-Learning (
+1.0Reward &-1.0False-Positive Penalty):- Confirmed vulnerabilities and regressions strengthen synaptic weights up to
0.9990. - Run
--false-positive <RULE_ID>to apply a real-1.0Bellman penalty (0.5000 -> 0.1887) that auto-mutes noisy rules for your project (Q < 0.25).
- Confirmed vulnerabilities and regressions strengthen synaptic weights up to
🪝 Automatic Immune System (
--install-hook):- Installs a
.git/hooks/pre-commitguard that audits staged changes in ~19ms before vulnerable code or regressions can enter Git.
- Installs a
🔄 Team Brain Sync via Deterministic JSON:
- All 5
brains/*.jsonfiles are saved with deterministically sorted keys for clean Git diffs — when Developer A trains the swarm on a bug today, Developer B runsgit pulltomorrow and inherits the immunity.
- All 5
📊 Offline 1-File Executive Dashboard (
--report):- Generates
swarm-report.html(zero external dependencies) with synaptic evolution bars per brain, detected regressions, and the latest SHA-256 episode seal.
- Generates
🚀 Quick Start (1 Command)
# 1. Run the 5-agent swarm and generate the offline visual HTML dashboard
node .agents/skills/sovereign-moe-swarm/scripts/treinar-enxame-moe.cjs ./src --report
# 2. Install the automatic 19ms Git pre-commit hook
node .agents/skills/sovereign-moe-swarm/scripts/treinar-enxame-moe.cjs --install-hook
# 3. Teach the swarm a project-specific false positive (applies -1.0 Q-Learning penalty)
node .agents/skills/sovereign-moe-swarm/scripts/treinar-enxame-moe.cjs --false-positive AST-03-DEPENDENCY-TYPOSQUATTING
# 4. Structured JSON or GitHub SARIF output for IDE agents & CI/CD
node .agents/skills/sovereign-moe-swarm/scripts/treinar-enxame-moe.cjs ./src --format=sarif
📋 Example Output
================================================================================
⚖️ BIDIRECTIONAL Q-LEARNING — FALSE POSITIVE PENALTY (-1.0) APPLIED
================================================================================
🧠 Brain: 🧬 AstQualityExpert (brain-ast-quality.json)
🎯 Rule: AST-03-DEPENDENCY-TYPOSQUATTING
📉 Q(s,a): 0.5000 -> 0.1887 [Reward R = -1.0]
🔇 Status: AUTO-MUTED IN PROJECT (Q < 0.25)
================================================================================
🔒 Privacy & Compatibility
- 100% Local Execution: Zero telemetry, zero external network calls, zero API keys required.
- Requirements: Node.js 18+ only. Works with TypeScript, JavaScript, Next.js, Node.js, Python (FastAPI/Django), and PostgreSQL/Supabase SQL.

