Maggy Engineering System

repository·main·Indexed 20 days ago

https://github.com/alinaqi/maggy

An engineering harness designed to enhance Claude Code with multi-model semantic routing, parallel agent execution via Polyphony, and intent-based testing through the Telos framework. It includes the maggy-harness for a FastAPI server and web dashboard, a 13-tier model routing system based on semantic blast scores, and behavioral evaluation tools for testing coding skills using task.md and criteria.json.

Tokens
380.6K
Snippets
836
Records
1.3K
Agent score
71%

What's inside Maggy

  1. Overview of the Maggy v2 Multi-Project Dashboard

    main

    The Maggy v2 Dashboard is a multi-project command center designed to provide developers with a unified view of their development ecosystem. It aggregates data from various backend modules to provide visibility into task management, resource consumption, and agent performance.

    Key monitoring areas include:

    • Inbox: AI-ranked tickets aggregated from GitHub Issues, Asana, Linear, and Jira.
    • Budget: Real-time token spend tracking per provider with burn rate trends (using green/yellow/red status indicators).
    • Agents: Monitoring of active Polyphony containers, including current tasks, models being used, and progress.
    • CIKG (Competitive Intelligence): Visualization of the competitive landscape, gap maps, and threat radars.
    • Process Health: Trends in CI pass rates, review rounds, and CodeRabbit findings.
    • Model Performance: Reward heatmaps derived from the routing table.
  2. Overview of Maggy v4.0 features

    main

    The current version (v4.0) of Maggy provides several core capabilities for autonomous AI engineering:

    • Skills system: Markdown-based instructions for AI agents (covering TDD, security, iCPG, Mnemos, etc.).
    • Polyphony: Container-isolated multi-agent orchestration (includes 173 tests and 14 modules).
    • iCPG: Intent-augmented code property graph featuring blast radius scoring.
    • Mnemos: Task-scoped memory lifecycle utilizing a typed MnemoGraph.
    • Cross-agent delegation: Complexity-based task routing to models like Codex, Kimi, etc.
    • Skill-lint: Quality gates specifically for skill files.
    • Behavioral evals: A test framework designed to evaluate skill effectiveness.
  3. Overview of Maggy v5 Integration Testing Scope

    main

    Phase 10 focuses on end-to-end integration testing to validate that all Maggy components function as a coherent system. The testing scope covers the interaction between:

    • PiAdapter
    • Model routing
    • Mnemos multi-model
    • CIKG
    • Dashboard
    • Process intelligence
    • MCP Forge

    Success is defined by the ability to complete a full task flow (from ticket to deployment) without manual intervention and ensuring the model fallback chain (checkpoint → switch → continue) works end-to-end.

  4. Overview of the Autonomous Engineering Roadmap tiers

    main

    The roadmap is organized into three priority tiers designed to close the gap between the current code-intelligence stack and fully autonomous coding agents.

    Tier 1: High Leverage (Unlocks the rest)

    Focuses on critical feedback loops and safety:

    • Runtime observability: Provides production feedback signals to detect if code changes actually worked.
    • Verifiable contracts: Converts natural-language iCPG postconditions into machine-checkable property-based tests.
    • Human escalation protocol: Provides a formal channel to 'page a human' with a context packet when an agent is stuck.

    Tier 2: Valuable (Non-blocking)

    Focuses on operational stability and coordination:

    • Auto CODE_INDEX: Automatically derives the capability index from the graph.
    • Multi-agent coordination: Implements locking and negotiation when multiple agents touch the same code area.
    • Rollback & recovery: Provides automated revert paths when drift is detected.

    Tier 3: Frontier (Optional)

    Focuses on advanced optimization and multimodal capabilities:

    • Confidence calibration: A reinforcement loop to learn from past agent failures.
    • Cost / budget awareness: Implements hard budget stops to prevent agents from burning money in loops.
    • Multimodal ingestion: Enables 'Graphify-style' ingestion for repos containing docs, images, or video.
  5. Optimize web content for SEO and GEO

    main

    The web-content skill provides a framework for creating content optimized for both traditional Search Engine Optimization (SEO) and Generative Engine Optimization (GEO).

    Core Philosophy:

    • SEO: Focuses on ranking in search engine results pages (SERPs) to drive clicks.
    • GEO: Focuses on being cited by AI assistants (ChatGPT, Perplexity, Claude, Gemini) to drive citations.

    The Golden Rule: Write for humans, but structure for machines. AI systems prefer short, clear, fact-based content with clean formatting (headers, bullets, tables), standalone sections that can be quoted, and direct answers to questions.

  6. Summary of Maggy's competitive advantages

    main

    Maggy's core value proposition is built on five pillars:

    1. Self-improvement as a product: A formal multi-level control system for continuous improvement.
    2. Process intelligence: Learning from the full SDLC, including CI results, reviewer comments, and merge patterns.
    3. Autonomous team learning: Using Mesh to share typed, provenanced intelligence P2P without a central server.
    4. Model-agnostic design: Automatically learning which model is best for specific task types.
    5. Local-first architecture: Ensuring code never leaves the developer's machine, supporting offline work and privacy.
  7. Overview of Maggy Subsystems

    main

    Maggy is composed of several specialized subsystems that handle different aspects of the AI development lifecycle:

    • CIKG (Code Intelligence Knowledge Graph): Manages codebase nodes and technology detection.
    • Forge: Detects MCP (Model Context Protocol) capability gaps and suggests tools.
    • History: Parses CLI session history for Claude, Codex, and Kimi.
    • Improve: Handles self-improvement via signal collection and health scoring.
    • Budget: Manages daily token spend limits with per-provider breakdowns.
    • Model Router: Uses a reward-based heatmap for model selection by task type.
    • Heartbeat: Runs scheduled jobs like history refresh, engram expiry, and mesh sync.
    • Engram: Provides persistent memory with typed records and namespace isolation.
    • Event Spine: Enables structured event emission and querying across all services.
    • P2P Mesh: Facilitates multi-node session sync via WebSockets, scoped to organizations.
  8. Mnemos Fatigue Model and State Thresholds

    main

    Mnemos calculates a composite fatigue score based on four passively observable dimensions. This score determines the agent's current state and triggers automatic actions.

    Fatigue Dimensions

    • Token Utilization (0.40): context_window.used_percentage / 100. Measures context window fullness.
    • Scope Scatter (0.25): Ratio of unique directories touched in the last 30 tool calls. High scatter indicates an unfocused agent.
    • Re-read Ratio (0.20): Proportion of Read tool calls targeting files already read. High ratio indicates context degradation.
    • Error Density (0.15): Ratio of failed tool calls to total tool calls in the rolling window.

    State Thresholds and Auto-Actions

    StateScore RangeAuto-Actions
    FLOW0.00–0.40None
    COMPRESS0.40–0.60Micro-consolidation (compress 3 ResultNodes, evict 1 cold ContextNode, decay weights)
    PRE-SLEEP0.60–0.75Checkpoint written + consolidation
    REM0.75–0.90Emergency checkpoint, warning to agent
    EMERGENCY0.90+Emergency checkpoint, handoff instruction
  9. Avoid content anti-patterns for AI visibility

    main

    To prevent AI models from deprioritizing your content, avoid these common mistakes:

    • No dates: AI deprioritizes undated content.
    • Anonymous content: No author = no E-E-A-T.
    • Walls of text: Break up with headers, bullets, boxes.
    • Generic content: Add original insights, data, opinions.
    • Missing schema: Invisible to structured data crawlers.
    • Outdated info: Update quarterly minimum.
    • No FAQ: Missing easy GEO win.
    • Poor URL structure: Use /topic-name instead of /p=12345.
  10. Playwright E2E Testing Anti-Patterns

    main

    Avoid these common mistakes to ensure stable and maintainable tests:

    • Hardcoded waits: Never use sleep or waitForTimeout. Use web-first assertions.
    • Brittle selectors: Avoid CSS or XPath selectors; prefer getByRole, getByText, or getByTestId.
    • Testing third-party sites: Mock external dependencies instead of interacting with them directly.
    • Shared state: Ensure each test is isolated and does not depend on the side effects of a previous test.
    • Missing awaits: Always await asynchronous operations to prevent race conditions.
    • Testing implementation details: Focus on user-visible behavior rather than internal code structures.
  11. How Maggy's Auto-Seed process works

    main

    Maggy uses an autonomous AUTO-SEED process triggered upon project registration to eliminate manual configuration. Instead of requiring a user to define policies, Maggy spawns a Pi agent (using a cost-effective model like qwen or kimi) to perform a deep analysis of the project's history.

    The Seeding Workflow

    1. Detection: Maggy detects a new project in the registry.
    2. Analysis: The Pi agent executes a series of commands to extract patterns:
      • GitHub Data: Uses gh CLI to analyze PR sizes, review rounds, time-to-merge, and reviewer patterns (gh pr list, gh pr view).
      • CI/CD History: Uses gh api to check CI pass/fail rates and identify flaky tests.
      • Git History: Uses git log to detect reverts and branch naming conventions.
      • Structural Analysis: Uses codebase-memory-mcp (get_architecture and search_graph) to understand module structure and dependency depth.
    3. Database Seeding: The agent writes findings to specialized databases:
      • process_patterns.db (review comments)
      • ci_patterns.db (CI failures)
      • pr_patterns.db (merge velocity)
      • task_history.db (git log data)
      • environments/{project}.yaml (workflow configuration)
    4. Policy Generation: An initial policy.yaml is automatically computed based on these patterns (e.g., if ruff failures are frequent, it enables a pre-check).
    5. Ledger Entry: The seed is recorded as modification #1 in the improvement_ledger to serve as the baseline for all future autonomous optimizations.

    Benefits

    • Zero Configuration: No manual setup or flag-driven seeding required.
    • Low Cost: Uses cheap models for structured data extraction (~$0.10-$0.50 per project).
    • Immediate Value: Provides a "Day 1 Analysis" dashboard showing predicted improvements based on historical data.
    // Example of Day 1 Analysis output
    MAGGY — Day 1 Analysis (auto-generated from project history)
    
    zensurveys-backend (200 PRs analyzed):
      Current process health:
        CI first-pass rate: 72%
        Avg review rounds: 2.8
        Top review comment: "add error handling" (23 times)
        Avg time-to-merge: 36h
    
      Predicted improvements if Maggy had been active:
        CI first-pass rate: 72% → ~94% (pre-lint + pre-type)
        Review rounds: 2.8 → ~1.4 (auto error handling + tests)
        Time-to-merge: 36h → ~12h (smaller PRs + fewer rounds)
  12. Use the 4px Base Spacing Grid

    main

    Maintain visual consistency by using a consistent spacing scale based on a 4px grid. Common values include xs: 4, sm: 8, md: 16, lg: 24, xl: 32, and 2xl: 48.

    // React Native spacing - consistent scale
    const spacing = {
      xs: 4,
      sm: 8,
      md: 16,
      lg: 24,
      xl: 32,
      '2xl': 48,
    } as const;
    
    // Usage
    const styles = StyleSheet.create({
      container: {
        padding: spacing.md,
        gap: spacing.sm,
      },
    });