Skip to content

About

Autonomous AST Program Repair, Time-Travel Debugger & Self-Healing Execution Sandbox. Built with Hexagonal Ports & Adapters, Tree-Sitter C grammars, a Two-Tier Multi-Agent Debate Loop, and isolated subprocess test verification.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

πŸ›‘οΈ GhostSlate

Autonomous AST Program Repair, Time-Travel Debugger & Self-Healing Execution Sandbox. Built on Hexagonal Ports & Adapters with Tree-Sitter C grammars, a Two-Tier Multi-Agent Debate Loop (Triage Synthesizer ↔ Adversarial Critic), and an isolated subprocess test runner guaranteeing 100% Green verification before code suggestions are displayed.

FastAPI Backend Frontend Studio AST Engines Sandbox Harness Architecture License: MIT Publisher Keep Render Warm


LIVE DEMO


✨ Features

🎯 Tree-Sitter AST Scoping & Surgical Node Isolation

  • No Whole-File Hallucinations: Traditional AI coding tools perform destructive whole-file rewrites that wipe comments, format unrelated blocks, and alter surrounding logic. GhostSlate uses Tree-Sitter C grammars and Python AST to isolate the exact syntax node (IfStatement, MethodBody, Comparison) responsible for the breach.
  • Enclosing Scope Bounds: Intelligently maps syntax coordinates (start_point to end_point) and preserves surrounding indentations, types, and class structures intact.

⏳ State Invariant Time-Travel Scrubber

  • Frame-by-Frame Execution Playback: Don't just inspect where an error triggeredβ€”scrub backwards and forwards in time to inspect how state mutated into corruption.
  • Live Variable Delta Inspection: Dynamic variable scope cards show real-time variable mutations at every execution frame.
  • Invariant Breach Alerting: Automatically traps invalid states (e.g. negative balances, boundary overflows, null pointer dereferences, or ledger imbalances) and highlights the culprit variable, expected invariant condition, and corrupt runtime value.

πŸ€– Two-Tier Multi-Agent Debate Loop

  • ⚑ Triage Agent (Synthesizer): Analyzes the runtime invariant violation, identifies the faulty AST node, and crafts a minimal reproducible unit test alongside a surgical diff patch.
  • πŸ›‘οΈ Adversarial Critic (Auditor): Actively red-teams proposed patches against edge cases, boundary conditions, and type invariants (e.g. barring negative transaction inputs or typecasting nullable JSON tokens).
  • Consensus Gating: The patch only moves to execution when both agents reach cryptographic consensus and issue an audit approval.

πŸ§ͺ Deterministic Sandbox Runner (Subprocess Isolation)

  • Zero Demo Flakiness: Runs inside an ephemeral temporary workspace using Python subprocess isolation.
  • Strict Verification Gate: Code patches are never marked as valid or merged unless internal tests transition from ❌ Red Failed (Exit 1) to βœ… 100% Green Passed (Exit 0).
  • Microsecond Timing: Sub-second execution benchmarking with cryptographic proof tokens.

πŸ“ Monaco AST-Scoped Diff Studio

  • High-Fidelity Code Studio: Embedded Monaco Diff Editor with side-by-side and inline visual diff toggles.
  • Unified Diff Metrics: Real-time calculation of inserted, modified, and deleted lines, proving minimal change radius.
  • 1-Click Copy: Instant clipboard export for git patches and unified diffs.

πŸ’₯ Interactive Chaos Injection Simulator & Custom Sandbox

  • One-Click Bug Scenarios & Live Code Studio: Pre-configured with 6 realistic scenarios including arbitrary user code execution:
    1. Concurrent Order Book Race Condition (Double-spending & negative balances)
    2. Sliding Window Rate Limiter Off-By-One (len(timestamps) <= max_requests boundary bug)
    3. JWT Auth Context Null Pointer (NoneType member dereference)
    4. Double-Entry Financial Ledger Imbalance (Solvency conservation failure)
    5. High-Priority Stream Interrupt & Causal Watermark (Monotonic sequence reordering)
    6. Custom Evaluator Sandbox (Interactive source code & pytest assertion studio with live dynamic AST repair)
  • 5-Stage Visual Stepper: Watch the healing pipeline progress live through Invariant Breach β†’ AST Isolation β†’ Agent Debate β†’ Subprocess Pytest β†’ 100% Green Verified.
  • Hands-Free Keyboard Shortcuts: Rapid-fire hotkeys (1-6 scenario select, Space trigger heal, E export PR, ? shortcuts cheat sheet, Esc dismiss).

πŸ“¦ 1-Click Pull Request & SARIF Compliance Exporter

  • Production-Ready PRs: Generates formatted markdown Pull Request descriptions with root cause summaries, unified diffs, and deterministic sandbox proofs.
  • SARIF v2.1.0 Export: Direct export in Static Analysis Results Interchange Format for GitHub Security Code Scanning and CI/CD pipelines.

πŸ’¬ Challenge Card #2: Real-World Feedback & Community Iteration

Full Documentation & Visual Proofs: See the /feedback directory for conversation logs, community critique, and verified screenshots.
Public Outreach: Shared on LinkedIn (https://lnkd.in/p/ddR6nADX) tagging @GREVIX.

GhostSlate was shared directly with peer developers, students, and backend engineers to gather unfiltered critique on how developers would use autonomous program repair in production.

Contributor / Peer Community Role What People Told Us What We Changed Because Of It Status
Aarav S. Systems Engineer "The canned scenarios are great, but evaluators need to test their own code. Can I paste my own broken Python class and custom pytest assertion to see it self-heal live?" Built Interactive Custom Evaluator Sandbox: Added live code and test textareas with presets (Buffer Overflow, Token Bucket, Vault Solvency) and dynamic AST boundary repair. 🟒 Merged
Priya K. Full-Stack Developer "Switching scenarios and triggering heals with a mouse slows down live presentations. Can you add keyboard shortcuts?" Engineered Hands-Free Hotkeys: Added global hotkeys for 1-6 (scenario switch), Space (run heal), E (PR export), ? (shortcuts cheat sheet), and Esc. 🟒 Merged
Dev M. Distributed Systems Student "For the out-of-order interrupt scenario, how can I be sure the re-sequencing actually happened under 15¡s latency rather than being pre-computed?" Live Stream Sync Telemetry Banner: Integrated real-time jitter distance (frames), reordered frames count, causal watermark latency (¡s), and monotonic integrity proofs into the UI. 🟒 Merged

πŸ›οΈ Core Philosophy & Hexagonal Architecture

GhostSlate is built using an open, decoupled Hexagonal Ports & Adapters Architecture:

flowchart TB
    subgraph Presentation["πŸ–₯️ Presentation Adapters"]
        direction LR
        WebStudio["Monaco Web Studio<br><i>(React + Vite)</i>"]
        HeadlessCLI["Headless CLI Adapter<br><i>(SARIF / CI/CD)</i>"]
        REST_WS["FastAPI & WebSockets<br><i>(Streaming Engine)</i>"]
    end

    subgraph Core["πŸ›‘οΈ GhostSlate Core Domain Engine"]
        Trap["<b>State Invariant Trap</b><br>Captures frame-by-frame mutations"]
        ASTEngine["<b>AST Scoping & Surgery</b><br>Tree-Sitter C node isolation"]
        DebateLoop["<b>Two-Tier Agent Loop</b><br>Triage ↔ Adversarial Critic"]
        Sandbox["<b>Deterministic Sandbox</b><br>Isolated Subprocess Pytest"]
    end

    subgraph Providers["πŸ”Œ Provider Adapters"]
        direction LR
        DeterministicEngine["Offline Deterministic Engine<br><i>(100% Zero-Flake)</i>"]
        GeminiAdapter["Google Gemini 2.0 Flash<br><i>(Provider Adapter)</i>"]
        TreeSitterAdapter["Tree-Sitter Grammars<br><i>(Python & JS Bindings)</i>"]
        PyASTAdapter["Native Python AST<br><i>(Fallback Parser)</i>"]
    end

    Presentation ==> Core
    Core ==> Providers
Loading
  • Pluggable Presentation: Switch effortlessly between an interactive web canvas and a headless CLI bot for CI/CD pipelines.
  • Pluggable Intelligence: Run 100% offline using the built-in deterministic engine, or hot-swap with Google Gemini 2.0 Flash or OpenAI models without modifying core domain logic.
  • Pluggable Parsers: Load Tree-Sitter grammar bindings dynamically for Python, JavaScript, TypeScript, and Go.

βš™οΈ Platforms & Ecosystem Status

Module Platform Status Runtime Tech Stack
πŸ›‘οΈ GhostSlate Engine Backend / API 🟒 Active Python 3.10+ FastAPI, Pydantic, Tree-Sitter, Pytest
πŸ’» Diff Studio Web / SPA 🟒 Active Modern Browsers React, Vite, Monaco Editor, Lucide
πŸ€– Headless CLI Terminal / CI/CD 🟒 Active CLI (Cross-Platform) Python, SARIF v2.1.0, JSON
πŸ§ͺ Sandbox Runner Subprocess 🟒 Active Ephemeral Temp Pytest, Subprocess Isolation

πŸ› οΈ Tech Stack

Core Backend & AST Surgery

  • Language & Framework: Python 3.10+, FastAPI, Starlette, Uvicorn
  • AST Parsing: tree-sitter, tree-sitter-python, tree-sitter-javascript, Python ast
  • Verification Harness: pytest, isolated subprocess runners, tempfile
  • Data Validation: pydantic v2

Frontend Presentation Studio

  • Framework: React 19, Vite
  • Code Editor: @monaco-editor/react (Monaco Diff Editor)
  • Styling: Vanilla CSS with custom glassmorphic dark design tokens (backdrop-filter: blur(16px))
  • Typography: Google Fonts (Plus Jakarta Sans, JetBrains Mono)
  • Icons: lucide-react

πŸ“ Repository Architecture

GhostSlate/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ .gitignore                       # Python backend ignore rules
β”‚   β”œβ”€β”€ adapters/                        # Hexagonal adapter layers
β”‚   β”‚   β”œβ”€β”€ parsers/                     # AST grammar adapters
β”‚   β”‚   β”‚   β”œβ”€β”€ base.py                  # ASTParserPort interface
β”‚   β”‚   β”‚   β”œβ”€β”€ tree_sitter_parser.py    # Tree-Sitter C parser adapter (Python/JS)
β”‚   β”‚   β”‚   └── python_ast_parser.py     # Python standard library AST fallback
β”‚   β”‚   β”œβ”€β”€ presentation/                # Non-web presentation adapters
β”‚   β”‚   β”‚   └── cli_adapter.py           # Headless CLI with SARIF v2.1.0 exporter
β”‚   β”‚   └── providers/                   # Model intelligence adapters
β”‚   β”‚       β”œβ”€β”€ base.py                  # ModelProviderPort interface
β”‚   β”‚       └── deterministic_engine.py  # Zero-flake offline synthesis engine
β”‚   β”œβ”€β”€ chaos/
β”‚   β”‚   └── scenarios.py                 # 4 Production chaos scenarios & tests
β”‚   β”œβ”€β”€ core/                            # Core domain engine
β”‚   β”‚   β”œβ”€β”€ agent_loop.py                # End-to-end self-healing coordinator
β”‚   β”‚   β”œβ”€β”€ ast_engine.py                # Surgical AST splicing & diff computation
β”‚   β”‚   β”œβ”€β”€ models.py                    # Pydantic domain models
β”‚   β”‚   β”œβ”€β”€ sandbox_runner.py            # Subprocess test execution sandbox
β”‚   β”‚   └── state_trap.py                # Runtime state invariant & frame recorder
β”‚   β”œβ”€β”€ tests/
β”‚   β”‚   └── test_core.py                 # Comprehensive automated test suite
β”‚   └── main.py                          # FastAPI REST API & WebSocket server
β”œβ”€β”€ frontend/                            # React + Vite + Monaco web studio
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ ASTVisualizer.jsx        # Tree-Sitter syntax tree inspector
β”‚   β”‚   β”‚   β”œβ”€β”€ AgentDebateStream.jsx    # Dual-agent debate transcript stream
β”‚   β”‚   β”‚   β”œβ”€β”€ ChaosSimulator.jsx       # 1-Click chaos injection & pipeline stepper
β”‚   β”‚   β”‚   β”œβ”€β”€ ExportModal.jsx          # 1-Click PR & SARIF export modal
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.jsx               # Brand bar & provider selector
β”‚   β”‚   β”‚   β”œβ”€β”€ MonacoDiffStudio.jsx     # Side-by-side Monaco diff studio
β”‚   β”‚   β”‚   β”œβ”€β”€ SandboxTerminal.jsx      # Subprocess test terminal (Red -> Green)
β”‚   β”‚   β”‚   └── StateTimeTravelScrubber.jsx # Step-by-step state scrubber
β”‚   β”‚   β”œβ”€β”€ styles/
β”‚   β”‚   β”‚   └── index.css                # Futuristic glassmorphic dark theme
β”‚   β”‚   β”œβ”€β”€ App.jsx                      # Master studio controller
β”‚   β”‚   └── main.jsx
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
β”œβ”€β”€ pytest.ini                           # Pytest path discovery configuration
β”œβ”€β”€ .gitignore                           # Root git ignore specification
└── README.md                            # Master project documentation

πŸš€ Getting Started

1. Backend Setup

# Clone the repository
git clone https://github.com/saad2134/GhostSlate.git
cd GhostSlate

# Install Python dependencies
pip install fastapi uvicorn pydantic pytest tree-sitter tree-sitter-python tree-sitter-javascript

# Start the FastAPI engine (port 8000)
python -m uvicorn backend.main:app --host 127.0.0.1 --port 8000

2. Frontend Studio Setup

# In a new terminal, navigate to frontend
cd frontend

# Install dependencies
npm install

# Start the Vite development studio (port 5173)
npm run dev

Open your browser at http://127.0.0.1:5173 to launch GhostSlate.

3. Headless CLI Execution (CI/CD Mode)

You can run GhostSlate directly in headless CI/CD pipelines without opening the web interface:

# Run automated repair for a scenario and export a SARIF audit report
python -m backend.adapters.presentation.cli_adapter --scenario race_condition --output-sarif audit.sarif

πŸ”’ Security & Data Integrity

GhostSlate enforces strict defense-in-depth isolation across all program repair pipelines and sandbox execution environments:

  • Isolated Ephemeral Subprocess Sandboxes: Every candidate patch is tested in an ephemeral temporary directory generated with tempfile.TemporaryDirectory(). The test workspace is destroyed immediately after execution.
  • Sanitized Execution Environment (clean_env): Subprocesses run with a stripped environment dictionary that purges all parent process secrets, tokens, API keys, and sensitive environment variables (os.environ).
  • Subprocess Resource Quotas & Timeouts: Sandbox runs enforce a strict 5.0-second execution deadline (timeout=5.0). Infinite loops or hangs are forcefully terminated with SIGKILL / terminate(), preventing Denial of Service.
  • Arbitrary Code Execution Hardening: The sandbox runner inspects source strings for prohibited modules (os.system, subprocess.Popen, arbitrary sockets) prior to dispatch.
  • Cryptographic Diff Line Boundaries: Tree-Sitter AST parser enforces surgical coordinate boundaries, ensuring zero unauthorized mutations outside the enclosing target scope.

β™Ώ Accessibility (WCAG AA Compliance)

GhostSlate is built to comply with WCAG 2.1 AA accessibility guidelines across all interaction vectors:

  • Keyboard Navigation & Global Hotkeys:

    Shortcut Action Description
    1 ✦ 6 Scenario Switch Instant toggle across 6 chaos scenarios
    Space Trigger Heal Dispatches live chaos injection & automated AST self-healing loop
    E Export Modal Opens 1-Click GitHub PR markdown & SARIF v2.1.0 exporter
    ? or / Hotkey Cheat Sheet Toggles interactive keyboard shortcuts modal
    Esc Dismiss Overlays Closes any open modal or active dialog
  • Skip to Content Landmark: Features a top-level <a href="#main-content" class="skip-to-content"> allowing screen reader and keyboard-only users to bypass navigation straight to the interactive sandbox.

  • Semantic HTML5 Landmarks: Built using <header>, <main id="main-content">, <nav>, and <footer> with explicit aria-label tags on all interactive buttons and icons.

  • Touch Targets & Contrast: All interactive controls maintain minimum 44px touch envelopes with high-contrast text ratios exceeding WCAG AA standards (4.5:1 for body copy, 7:1 for headers).


🎨 Design Philosophy & Aesthetics

GhostSlate adheres to a strict Vercel High-Contrast Monochrome visual design system:

  • Pitch-Black Core Canvas: #000000 pitch black background paired with elevated #0a0a0a card backdrops and hairline #222222 (var(--border-subtle)) borders.
  • Functional State Accents:
    • Emerald (#10b981): 100% Green Verified test passes and causal stream sync active state.
    • Crimson (#ef4444): Invariant breaches, failed tests, and AST deletion diff lines.
    • Amber (#f59e0b): Isolated AST target nodes, jitter warnings, and candidate repair warnings.
    • Sky (#38bdf8): Subprocess execution and temporary workspace orchestration.
  • Non-Blocking Fluid Typography: Uses Geist, JetBrains Mono, and Inter loaded asynchronously via non-blocking media queries for optimal First Contentful Paint (FCP).
  • Aceternity UI Micro-Interactions: Subtle spotlight borders (SpotlightCard), fluid decrypted text reveals (DecryptedText), count-up counters, and animated shimmer action buttons (ShimmerButton).

πŸ§ͺ Test Suite & Verification

All automated tests in GhostSlate are deterministic and run offline with zero cloud dependency.

Test Matrix & Coverage Summary

Test Module Suite Focus Verified Invariants Tests Status
backend/tests/test_core.py Chaos Scenarios & Self-Heal Race condition, Off-by-one, NullPointer, Ledger solvency, Custom Sandbox, SARIF export 7 🟒 100% Pass
backend/tests/test_stream_sync.py Causal Stream Resequencing In-order ingest, Out-of-order jitter buffer, High-priority interrupt interception, <15¡s watermark latency 5 🟒 100% Pass
Total Test Suite Hexagonal Core & Stream End-to-End AST Repair & Deterministic Pytest Gate 12 / 12 🟒 100% Pass

Running Full Automated Test Suite

# Run complete test suite with verbose output
pytest backend/tests/ -v
============================= test session starts =============================
platform win32 -- Python 3.10.6, pytest-8.3.5, pluggy-1.6.0
rootdir: C:\Users\UwU\Desktop\app-projects\GhostSlate
configfile: pytest.ini
collected 12 items

backend/tests/test_core.py::test_all_chaos_scenarios_configured PASSED   [  8%]
backend/tests/test_core.py::test_custom_self_heal_loop PASSED            [ 16%]
backend/tests/test_core.py::test_stream_interrupt_self_heal_loop PASSED  [ 25%]
backend/tests/test_core.py::test_race_condition_self_heal_loop PASSED    [ 33%]
backend/tests/test_core.py::test_off_by_one_self_heal_loop PASSED        [ 41%]
backend/tests/test_core.py::test_null_pointer_self_heal_loop PASSED      [ 50%]
backend/tests/test_core.py::test_financial_ledger_self_heal_loop PASSED  [ 58%]
backend/tests/test_core.py::test_sarif_export_structure PASSED           [ 66%]
backend/tests/test_stream_sync.py::test_stream_in_order_ingest PASSED    [ 75%]
backend/tests/test_stream_sync.py::test_stream_out_of_order_resequencing PASSED [ 83%]
backend/tests/test_stream_sync.py::test_stream_high_priority_interrupt_interception PASSED [ 91%]
backend/tests/test_stream_sync.py::test_stream_latency_and_watermark_metadata PASSED [100%]

============================= 12 passed in 19.32s =============================

πŸ—ΊοΈ Product Roadmap

Phase Milestone Focus Areas Key Deliverables Status
v1.0 Deterministic Core & Web Studio AST Program Repair & Time-Travel Tree-Sitter C parser bindings, Python AST fallback, isolated subprocess pytest sandbox, Monaco Diff Studio, State Time-Travel Scrubber, Two-Tier Agent Loop, and SARIF v2.1.0 exporter. 🟒 Released
v1.5 Multi-Language Grammar Expansion Cross-Language Coverage Dynamic loading of Go and Rust Tree-Sitter grammars, integration with cargo test and go test subprocess runners. ⏳ Planned
v2.0 Native GitHub Action & Bot Continuous Self-Healing Automated GitHub PR bot that intercepts failing CI runs, isolates faulty AST nodes, and submits verified PR fixes automatically. ⏳ Planned

πŸ“Š Project Stats

Repo Size Last Commit License Forks Stars Watchers


πŸ‘€ Publisher

Developed and published by Saaduddin Mohammed (@saad2134)


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

  • βœ… Commercial use
  • βœ… Modification
  • βœ… Distribution
  • βœ… Private use
  • ❌ Liability
  • ❌ Warranty

🏷️ Tags

ast-repair self-healing program-synthesis tree-sitter fastapi react vite monaco-editor time-travel-debugger pytest hexagonal-architecture subprocesses sarif python open-source developer-tools

About

Autonomous AST Program Repair, Time-Travel Debugger & Self-Healing Execution Sandbox. Built with Hexagonal Ports & Adapters, Tree-Sitter C grammars, a Two-Tier Multi-Agent Debate Loop, and isolated subprocess test verification.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages