Skip to content

Instantly share code, notes, and snippets.

@jmanhype
Created January 27, 2026 17:42
Show Gist options
  • Select an option

  • Save jmanhype/8e08f5b22dc5a2d08bdc8451508eba79 to your computer and use it in GitHub Desktop.

Select an option

Save jmanhype/8e08f5b22dc5a2d08bdc8451508eba79 to your computer and use it in GitHub Desktop.
Wreckit Code Archaeology: Forensic Analysis

Wreckit: Code Archaeology & Forensic Analysis

Date: 2026.01.27
Focus: Forensic audit of the "Ralph Wiggum Loop" codebase

This report analyzes the structural evolution and technical "DNA" of Wreckit, identifying the legacy layers and the strategic impact of the new RLM architecture.


🏛️ Evolutionary Layers

1. The Legacy Layer (The Subprocess Era)

  • Mechanism: spwaning claude or amp as external child processes.
  • Evidence: src/agent/process-runner.ts (extracted from the monolithic runner.ts).
  • DNA Signature: Use of <promise>COMPLETE</promise> signals and manual stdout/stderr buffering. Brittle but highly compatible.

2. The Migration Layer (SDK Transition)

  • Mechanism: Integration of @anthropic-ai/claude-agent-sdk.
  • Evidence: src/agent/dispatcher.ts and the AgentConfigUnion schema.
  • DNA Signature: Discriminated unions (kind: "claude_sdk") used to bridge the gap between "dumb" processes and "smart" in-process SDK calls.

3. The RLM Layer (The "Infinite Context" Architecture)

  • Mechanism: Recursive Language Models via JSRuntime.
  • Evidence: src/agent/rlm-runner.ts and src/agent/rlm-tools.ts.
  • Innovation: Moving the prompt from the model's context window to a sandboxed Node vm. This represents a fundamental shift from "Prompt Engineering" to "Context Engineering".

⛓️ Technical Debt Hotspots

  1. The Git God-Object: src/git/index.ts is a 1200+ line monolith handling everything from branch cleanup to secret scanning. It uses a global mutex to serialize all operations—a legacy of historical concurrency issues.
  2. State Machine Fragility: The "truth" of item states is scattered across three files: states.ts, phase.ts, and itemWorkflow.ts. Desynchronization here is a high risk.
  3. Pattern Duplication: Every workflow phase (research, plan, implement) implements its own while(attempt < maxAttempts) retry loop with nearly identical validation logic.
  4. The Deprecation Trail: 11 @deprecated markers currently exist in runner.ts and index.ts. The codebase is in a state of "permanent transition".

🏗️ Load-Bearing Hacks

  • Z.AI Proxy: The system forces Z.AI support by mapping ANTHROPIC_AUTH_TOKEN to the SDK's apiKey field and overriding the apiURL.
  • Manual JIT Context: The skill loader (Item 033) injects files into the agent's context just-in-time, a precursor to the full RLM "offloaded context" model.
  • The "I SEE YOU" Pattern: A specific confirmation message used to verify that agents have successfully bypassed their context window to read offloaded data.

📈 Strategic Recommendation

  1. Extract PhaseExecutor: Consolidate the duplicated retry/validation loops into a single service.
  2. Modularize Git: Split the 1200-line git module into git/branch.ts, git/pr.ts, and git/status.ts.
  3. Unified State truth: Centralize the state progression logic into states.ts and have the workflow derive from it programmatically.

🔗 Forensic Map

  • Core Engine: src/agent/
  • State Machine: src/domain/
  • Workflow Runner: src/workflow/itemWorkflow.ts
  • Self-Healing: src/agent/healingRunner.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment