~/blog

A Homelab Code Factory: How I Wired Paperclip, OmniRouter, a Fleet of LLMs, and GitLab into One Continuous Pipeline

23/10/2026 · 4 min

1. The Big Picture: Full Pipeline Topology

The entire journey from initial task submission to battle-tested code takes place within a private network across dedicated virtualisation nodes:


Step-by-Step Breakdown:


  1. [PROMPT] Task Dispatch: I submit the task ticket specifying architectural constraints, edge cases, and expected acceptance tests.
  2. [ORCHESTRATION] Paperclip: Picks up the task, provisions an isolated scratchpad workspace, and injects the project's living architectural schema.
  3. [AI GATEWAY] OmniRouter: Inspects prompt characteristics, current rate limits, and token budgets, routing requests dynamically to the optimal provider.
  4. [MODEL FLEET] Multi-Provider Fleet:
    • Frontier: Claude Code / Antigravity / Codex / Mistral Large (deep reasoning, high-stakes refactoring).
    • Aggregators & High-Throughput: OpenRouter / KiloGateway / Trae / Gemini CLI (huge context windows, load balancing).
    • Self-Hosted Local: LM Studio in local LAN (sensitive configurations, internal logs, zero-cost syntax verification).
  5. [EXECUTION & AUDIT] Git Worktree: The agent applies modifications within an isolated branch and executes the verification harness (typecheck, lint, unit & regression tests) strictly bound to AGENTS.md.
  6. [DELIVERY] Self-Hosted GitLab: Verified code is pushed as a dedicated branch and opens an automated Merge Request (MR). GitLab CI triggers container image builds and database migration rehearsals, leaving final approval to human review.

2. The Orchestration Heart: Paperclip

Inside my homelab infrastructure runs Paperclip — the central orchestrator and task dispatcher for autonomous coding agents.

When a feature needs building or an issue needs resolving, I don't paste snippets into a browser. I dispatch the task into Paperclip:

  • Quarantined Scratchpads: Paperclip allocates an isolated workspace per ticket. The agent can compile, test, break, and fix things without polluting the main repository.
  • Compounding Knowledge (Persistent Wiki): Naive RAG setups rediscover the wheel on every query by blindly vector-searching random chunks. Paperclip, by contrast, compiles and maintains a structured knowledge base. If an agent discovers an undocumented quirk in a Payload CMS schema, a reverse-proxy routing rule, or an animation frame budget, that insight is distilled directly into the project's persistent wiki.
  • State Continuity: Successive runs don't start blind. The agent knows what was attempted in prior steps, which diffs failed assertions, and why.

3. The Token Exchange: OmniRouter and Local LM Studio

Paperclip never talks directly to external LLM provider endpoints. All execution traffic routes through a unified gateway: OmniRouter.

Within OmniRouter, an auto-router engine continuously evaluates prompt complexity, provider health, token quotas, and cost efficiency:

  1. Top-Tier / Architecture (Heavy Reasoning):
    • Claude Code
    • Antigravity
    • Codex / Mistral Large
  2. Aggregators & Specialized Engines (Flexibility & Scale):
    • OpenRouter & KiloGateway — access specialized models without juggling dozens of individual enterprise contracts.
    • Trae & Gemini CLI — for rapid multi-branch exploration and queries requiring 1M+ token contexts.
  3. Self-Hosted Local: LM Studio:
    • A dedicated workhorse machine sitting on the local network.
    • Handles tasks that have no business leaving the LAN (inspecting private server logs, parsing environment configs, bulk linting, and boilerplate generation).
    • Cost: $0. WAN overhead: 0 ms.

Zero-Downtime Failover: Surviving 429 and 529 Outages

When a frontier provider hits capacity (529 Overloaded) or exhausts a per-minute rate limit (RPM/TPM), OmniRouter's auto-router switches streams in milliseconds to a designated fallback with equivalent capabilities (e.g. pivoting from an external gateway to Mistral or Gemini). The agent in Paperclip doesn't abort mid-task — it keeps writing code uninterrupted.


4. Execution and Audit: Ironclad Worktree Rules

Once a model outputs changes, engineering discipline kicks in within an isolated Git Worktree:

  1. AGENTS.md as Living Law: Every agent must respect the project's working agreement. That means strict TypeScript (zero any), zero direct pushes to main, and performance-critical loops (such as ASCII canvas animations) engineered to avoid Garbage Collection pauses and guarantee steady 60 FPS.
  2. Compilation and Automated Verification: Before code leaves the worktree, the verification suite runs headlessly:
    bash
    npm run lint && npm run typecheck && npm test
    If any check fails, the model is required to fix its implementation in a subsequent turn.
  3. Sanitizing Commit History (Rule 9): AI tooling loves appending clutter like Co-Authored-By: Assistant... to commits. Our integration tooling strips unwanted trailers, ensuring an authentic and professional Git history.

5. The Finale: Merge Request to Self-Hosted GitLab

This is the cornerstone of the entire philosophy: no agent has permission to autonomously deploy to production.

Once a branch passes every worktree check, it is pushed to self-hosted GitLab with CI/CD.

A Merge Request (MR) is opened automatically, containing:

  • A concise summary of changes and architectural rationale.
  • The list of modified files alongside test coverage results.
  • A reference to the originating Paperclip task ticket.

GitLab CI immediately triggers: building the production container, testing PostgreSQL migrations against a clean scratch instance, and validating end-to-end routing.

I receive a notification, review the clean diff in GitLab, and approve the merge with one click. A Dockhand webhook picks up the signal, pulling the fresh image and redeploying the site in seconds.


Why This Architecture Wins

Most developers treat LLMs as chatty autocomplete engines. In my setup, AI is an integrated, audited subcontractor wired directly into infrastructure:

  • Paperclip preserves context and orchestrates tasks with zero amnesia.
  • OmniRouter slashes token bills, neutralizes API outages, and seamlessly blends cloud power with a local LM Studio node.
  • Self-Hosted GitLab with CI/CD ensures that nothing ever hits production without explicit human sign-off.

This isn't "vibecoding". It is resilient, predictable, production-grade engineering.

#AI#Agentic Coding#Coding#Homelab#DevOps#Architecture#Self-hosted

Comments

No comments yet. Be the first.