coderg / README_CoderG_05292026.md
prashantmatlani's picture
latest README
0e97bdc
|
Raw
History Blame Contribute Delete
14.1 kB

A newer version of the Gradio SDK is available: 6.19.0

Upgrade

CoderG β€” Autonomous Multi-Agent Technical Architecture & Reflection Framework

CoderG is an agentic, multi-worker workflow orchestrator designed to analyze software repositories, generate comprehensive course content or developer documentation, perform autonomous non-destructive background audits, and securely manage the version control deployment lifecycle.

Constructed on a foundation of First Principles Thinking and constrained by Ockham's Razor, CoderG strictly separates high-complexity generative operations and background code simulations from structural file-system modifications and remote cloud platform mutations. It introduces a multi-tier human-in-the-loop authorization layout to review, authenticate, and commit assets safely.


🎯 Project Profile

1. Project Scope

The core boundary of CoderG encompasses providing an automated, terminal-isolated development assistant that acts as a technical partner and instructor. The application reads codebase contexts, dynamically builds comprehensive learning or deployment documentation frameworks, writes files natively across diverse extensions, runs autonomous background code reflection/audit loops, and manages full Git versioning pipelines securely.

2. Core Operational Requirements

  • Context Token Safety: Dynamically handles dense repository files without triggering Context Length or Tokens Per Minute (TPM) failures by implementing sliding history limits.
  • Decoupled Responsibilities: Code inference, background structural auditing, local file serialization, Git transportation, and telemetry logging reside in fully decoupled, isolated scripts.
  • Dual-Gated Manual Authorization: 1. Deployment Gate: No automated code generations can interact with or push to remote Git platforms without manual credential approval from the deployment tower.
    1. Audit Patch Gate: Background optimization proposals generated during reflection states are completely barred from altering local files until the operator explicitly clears the code patch.
  • Destruction Resilience: Mandatory preservation of historical artifact records using shadow copies (_-1) before fresh disk write events occur.
  • Zero Storage Footprint: Complete programmatic purging of ephemeral workspace directories immediately following data transportation.

πŸ› οΈ Core Tools & Tech-Stack Employed

  • Presentation Engine: Gradio (v5/v6+) β€” Utilizes reactive state mechanics, streaming token interface pipelines, modern unified gr.Group containers, and asynchronous event handshaking loops.
  • Inference & Reflection Core: Groq Client SDK (llama-3.1-8b-instant) β€” Configured with independent operational parameter profiles to ensure technical predictability and programmatic format compliance.
  • Transport Driver: GitPython Framework & Native Git Core β€” Powers local repository instantiation, metadata index additions, and automated staging trees.
  • Infrastructure Layer: GitHub REST API v3 Engine β€” Automates remote cloud platform discovery, profile querying, and repository initialization on headless environments.
  • Format Serialization Compilers: PyYAML, TOML, python-docx β€” Decodes plaintext generator responses directly into precise technical configuration scripts and professional document layouts.

πŸ—οΈ Core Architecture Overview

CoderG bypasses monolithic script patterns by delegating discrete execution tasks across highly specialized micro-agents:

                     +-----------------------------------------+
                     |            app.py (Manager)             | <--- Gradio Presentation Control
                     +-----------------------------------------+
                                          |
     +------------------------+-----------+-----------+------------------------+
     |                        |                       |                        |
     v                        v                       v                        v
+------------------+    +------------------+    +------------------+    +------------------+
|  core_logic.py   |    |  dream_agent.py  |    |  file_agent.py   |    |   git_agent.py   |
|   (The Brain)    |    | (The Reflector)  |    |   (The Writer)   |    |  (The Courier)   |
+------------------+    +------------------+    +------------------+    +------------------+
|                        |                       |                        |
+------------------------+-----------+-----------+------------------------+
|
v
+-----------------------------------------+
|        agent_logging.py (Audit)         | ---> outputs/agent.log
+-----------------------------------------+

Module Component Breakdown

  1. app.py (Control Tower & UI Layer): An asymmetric Gradio interface managing dynamic conversation sessions, asynchronous text streaming execution, state tracking, and telemetry log piping. It coordinates async processing chains to cleanly refresh components sequentially while isolating session passwords to prevent global state bleeding.

  2. core_logic.py (Brain & Reasoning Engine): Handles user request context routing, applies token-safety cutoff mechanisms, and injects system architectures via prompt directives. It slices conversational history down to the last 3 active turns to maintain strict token boundaries and manages a shadow copying mechanism that duplicates pre-existing assets into a historical _-1 backup state prior to overwriting disk files.

  3. dream_agent.py (Persistence Layer & Audit Engine): Operates as a non-destructive background processing loop. It reads local workspace files, digests cognitive instructions from dream.md, and runs isolated simulation loops to locate efficiency bottlenecks or security anomalies. It relies on structured XML parsing (<proposed_patch>) to isolate recommended code changes from textual analysis.

  4. file_agent.py (Workspace Writer): A localized multi-format parser handling safe disk I/O actions. It automatically isolates content streams and securely compiles data structures into native .md, .txt, .yaml, .toml, or .docx layouts, employing format-specific processing frameworks (e.g., python-docx for virtual XML document models).

  5. git_agent.py (Transport Courier): Performs hybrid Git routines. It queries the remote GitHub REST API v3 engine to provision missing repositories dynamically under a automated account profile, handles staging tree management via GitPython, and uses explicit finally blocks to execute full directory purges on temp_repo/ to ensure a zero storage footprint inside host containers.

  6. agent_logging.py (System Auditor): A zero-dependency, transactional time-stamped tracker writing every systemic action, error, observation, or confirmation out to a safe operational log file (outputs/agent.log).


πŸ“ System Lifecycle & Interaction Model

1. Active Interactive Generation Loop

[ User Input ]
β”‚
β–Ό
+────────────+         Streams Text Tokens
|   app.py   | <───────────────────────────────────────────────────────+
+────────────+                                                         β”‚
β”‚                                                                β”‚
β”‚ Invokes Event Processing                                       β”‚
β–Ό                                                                β”‚
+────────────+         Passes Raw Artifacts        +───────────────+   β”‚
| core_logic | ──────────────────────────────────> |  file_agent   | ──+
+────────────+                                     +───────────────+
β”‚                                                    β”‚
β”‚ Writes Workspace Files                             β”‚ Creates Backups
β–Ό                                                    β–Ό
+────────────+         Executes Remote Push        +───────────────+
| git_agent  | <────────────────────────────────── |   outputs/    |
+────────────+          via Control Tower          +───────────────+
β”‚
+───> [ API Provision Check ] ───> Pushes Assets to Remote GitHub Target
β”‚
β–Ό
+────────────+
| temp_repo/ | ───> Purges Folder Completely on Termination (Zero Footprint)
+────────────+

2. Gated Cognitive Reflection Loop (Dream Mode)

[ Click Trigger ] ───> Ingests Target Files & dream.md ───> Groq Inference Engine (Temp 0.0)
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             Generates Structural Analysis
β”‚  UI INTERCEPT PANEL ENFORCES VISIBLE GAPE  | <───────────  & XML <proposed_patch> Tag
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
Operator Action Evaluated
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β–Ό                         β–Ό
[ APPROVE ]                [ DISCARD ]
β”‚                         β”‚
Executes File Write       Flushes State Buffer
& Creates .bak Check     & Collapses Panel
β”‚                         β”‚
β–Ό                         β–Ό
Live Codebase Altered      Workspace Left Untouched

πŸŽ›οΈ Dual-Gate Human-in-the-Loop Configurations

Gate 1: Remote Transport Control (Push to GitHub)

The interface employs a visual checkpoint to signify that it has paused and is explicitly awaiting a deployment decision. At the conclusion of a streamed response text in the central chat window, a bold status flag appears:

βœ… Files successfully generated in localized staging environment. β—Œ Awaiting authorization control panel to push to GitHub.

The chat stream halts, and the right-hand panel (πŸ“Š Deployment Telemetry Logs) transitions into a holding state (_Awaiting local environment staging completion..._). If the operator is unsatisfied, they simply reply with correction prompts, causing core_logic.py to overwrite the staging area with updated content and reset the cycle. Clicking Approve & Push to GitHub clears the gate and triggers the transport sequence.

Gate 2: Local Code Mutation Control (Cognitive Dream Core)

When the operator clicks Trigger Autonomous Audit, dream_agent.py evaluates the codebase asynchronously. To safely handle the response, the interface leverages a modern layout containment system:

  • Structural Isolation Container (gr.Group): A visibility-controlled group panel wraps the code review layout, preventing layout scattering and forcing the review interface to appear or collapse as a single atomic element.
  • Gated Code Actions: The layout exposes a specialized Markdown visualization block that presents a clean code analysis to the user while storing the raw code changes securely inside a hidden gr.State variable buffer (active_proposal_state).
  • Transaction Resolution: Clicking Discard clears the hidden state and collapses the component without modifying local storage. Only clicking Apply Changes triggers the extraction engine, creates a .bak copy of the target file, and commits the patch to disk.

βš™οΈ Fine-Tuning Execution Profiles

To enforce format compliance, eliminate hallucination loops, and prevent truncated outputs during large codebase rewrites, the execution routines are split into specialized inference profiles:

Profile Mode Target Model Temperature Max Tokens Output Formatting Rules
Interactive Chat llama-3.1-8b-instant 0.2 Implicit Markdown blocks with text explanations. Sliced to last 3 message turns.
Query Optimizer llama-3.1-8b-instant 0.0 Implicit Single raw plain text query sentence, strictly under 50 characters.
Dream Reflection llama-3.1-8b-instant 0.0 4096 Strict XML wrapper tagging around production-ready complete code.

πŸš€ Strategic Roadmap & Enhancements

Phase 1: Context Capture Optimizations

  • Recursive Repository Ingestion Tooling: Implement a file processing pipeline that scans target directories, strips out noise text blocks, and uses Python's built-in ast (Abstract Syntax Tree) module to condense whole repositories down to clear functional structural maps before prompting the model.
  • Intelligent File Template Identification: Teach the system to automatically analyze output patterns. If an asset block starts with properties like [tool.poetry] or version:, the agent will bypass generic formatting fallback parameters and write the data directly out under matching .toml or .yaml file configurations.

Phase 2: Workflow Security & Collaboration Controls

  • Branch-Based Multi-Staging (PR Workflows): Transition from making direct commits onto primary branches to pushing automated code changes onto a structured sandbox branch (e.g., coderg-patch-v1), followed by raising formal GitHub Pull Requests automatically for team reviews.
  • Dynamic Webhook Observability: Set up explicit network listener endpoints inside the backend. If an outside team member modifies or changes files on the remote GitHub target branch directly, CoderG will capture the webhook payload notice and immediately synchronize its localized working directories.

Phase 3: Advanced Diagnostic Monitoring

  • Real-Time Telemetry Streaming: Connect a live log viewer component directly onto the Gradio Presentation