Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

1. The Research-Apply Pipeline


title: ‘Multi-Phase AI Pipeline: Decoupling Research from Code Generation’ authors:


This article documents a tool-agnostic Research-Apply pipeline for AI-assisted engineering. The core principle: decouple “finding truth” (knowledge retrieval) from “writing code” (code generation) to ensure local hardware stability and architectural alignment.

1. The Research-Apply Pipeline

ISO 29148: Appropriateness

The pipeline moves away from passive AI chat toward an Active (Agentic) Retrieval model. We decouple “finding truth” from “writing code” so that local models remain focused, accurate, and stable.

PhaseRoleAction
1. ResearchResearcherA lightweight local agent identifies relevant context from a large Knowledge Base via vector DB or retrieval mechanism.
2. PlanningArchitectA high-reasoning model (cloud or large local) processes the research results to generate a precise execution plan.
3. ExecutionEditorA local SLM applies the plan to the codebase in a clean context state, preventing GPU OOM.
4. ValidationCI/CD GatesAutomated hooks verify code integrity, architectural tags, and commit standards.
5. ReviewForensicHuman-led verification of changes.

Why Five Phases?

Each phase exists for a specific reason:

The key insight is the hard boundary between Planning and Execution: the Editor must start with a clean context, receiving only the plan and target files from the Architect. This prevents the unbounded VRAM/context growth typical of long interactive sessions.

2. Namespace Partitioning for RAG

The Problem: Standard RAG faces “Context Overload” when a Knowledge Base exceeds the functional context window of local models. Retrieving from a flat, undifferentiated collection introduces noise and reduces precision.

The Solution: Following the same separation-of-concerns principle as the Hub-and-Spoke Ecosystem Architecture, split retrieval into namespaced collections to maintain high precision:

NamespaceContentsUse Case
Global_WorkflowsOrganization-wide standards, ADRs, engineering policiesEnsuring compliance with cross-project conventions
Project_SpecificProject documentation, API specs, domain knowledgeGrounding in the specific codebase being modified

This partitioning ensures that:

Stage Injection Pattern

Retrieved snippets are injected into the Architect context during the Planning phase, before plan generation begins:

  1. Query both namespaces with the task description

  2. Rank and filter chunks by relevance score

  3. Inject the top-k chunks into the Architect’s system prompt or context window

  4. Cite sources in the generated plan for downstream traceability

This “pre-flight” retrieval ensures the plan is grounded in current organizational standards rather than stale model knowledge.

3. Pipeline Visualization

4. Implementation Considerations