Refactored Guide
Refactored Guide
md
# LLM-Powered Microservices Refactoring Pipeline: Implementation Guide
## 🚀 Executive Summary
**Core LLM Chain:** Qwen 3-32B → GLM-4-32B → Gemini Pro 2.5 → Claude Sonnet 4.
(Meta's Llama 3.1 70B is an optional refiner).
This guide is intended for developers, DevOps engineers, and project managers
involved in the project. It provides a quick start, architectural overview, and
step-by-step implementation tasks.
1. **Prerequisites**: Ensure you have access to necessary API keys (Nebius, Google
Vertex AI, Anthropic, PromptLayer, GitLab), Python 3.9+, Docker, `kubectl`, and
`helm`. See [System Requirements](#system-requirements).
2. **Configuration**:
* Set up API keys as environment variables (e.g., `NEBIUS_API_KEY`).
* Configure `~/.continue/config.json` for your IDE. See [Continue.dev
Configuration](architecture.md#continue-dev-ide-interface).
* Prepare your `project_specs.json` file. See [Project Specification File]
(architecture.md#project-specification-file-project_specsjson).
3. **Install Dependencies**:
```bash
pip install langchain langchain-community langchain-memgraph ollama
huggingface_hub promptlayer prometheus_client requests pytest
# For Elixir development
# Follow official Elixir installation guide for your OS
# Ensure mix and hex are available
```
4. **Run the Orchestrator (Example)**:
```bash
# Ensure NEBIUS_API_KEY and PROJECT_SPECS_PATH are set
export NEBIUS_API_KEY="your-nebius-api-key"
export PROJECT_SPECS_PATH="specs/project_specs.json" # Adjust path as needed
python llm_orchestrator_with_context.py
```
(This assumes `llm_orchestrator_with_context.py` and `specs/project_specs.json`
are in your current path).
5. **Explore Further**:
* For detailed system design, see [architecture.md](architecture.md).
* For step-by-step setup and usage, see [tasks.md](tasks.md).
---
________________
architecture.md
# System Architecture
## 1. Overview
The core principle is to automate and assist developers in the complex task of
modernization by leveraging AI for code generation, analysis, and review, while
maintaining high standards of code quality, security, and performance.
```mermaid
graph TD
A[Developer writes prompt in VS Code via Continue.dev] --> B{LangChain
Orchestrator};
B --> C[Load Context: GitLab (Code/Docs) & Memgraph (RAG)];
C --> D[1. Qwen 3-32B: Initial Elixir Code Generation from Perl/PHP];
D --> E[2. GLM-4-32B: Refactor Elixir Code for Style & Idiomatics];
E --> F[3. (Optional) Llama 3.1 70B: Deep Refinement/Optimization];
F --> G[4. Gemini Pro 2.5: Bug Scanning & Concurrency Analysis];
G --> H[5. Claude Sonnet 4: Final Code Polish & Review];
H --> I[Apply diff to codebase & Commit to GitLab];
I --> J[GitLab CI/CD Pipeline: Validate, Test, Scan, Build];
J --> K[Deploy to Kubernetes Environment (dev_1, dev_2, prod)];
Workflow Steps:
1. Prompt & Context Ingestion: The developer initiates a task (e.g., "Rewrite
AST_server.pl to Elixir") using Continue.dev in VS Code.
2. LangChain Orchestration: The llm_orchestrator_with_context.py script manages the
entire flow.
* Retrieves relevant project specifications from project_specs.json.
* Queries Memgraph (GraphRAG) for contextual code chunks, documentation
(VICIdial, FreeSWITCH, SignalWire), and relationships.
* Maintains conversation history and context using ConversationBufferMemory.
3. LLM Chain Execution:
* Qwen 3-32B: Generates initial Elixir code based on the legacy code, task
description, specs, and RAG context.
* GLM-4-32B: Refactors the Qwen-generated code, focusing on Elixir idioms,
style, and best practices.
* Llama 3.1 70B (Optional): Can be inserted here for further deep refinement,
performance optimization, or BEAM-specific tuning.
* Gemini Pro 2.5: Scans the refined code for bugs, race conditions, security
vulnerabilities, and FreeSWITCH/Kamailio integration errors, leveraging its large
context window.
* Claude Sonnet 4: Performs a final review for maintainability, readability,
performance, and alignment with project specs, providing polish and final
recommendations.
4. Code Validation & Commit: The resulting code is validated against
project_specs.json using validate_elixir_code.py. If successful, the changes are
proposed/committed to GitLab.
5. CI/CD Pipeline: A commit triggers the GitLab CI pipeline for further automated
checks and deployment.
3. Microservices Architecture
The goal is to decompose the monolithic legacy systems into a set of Elixir-based
microservices, potentially with a Next.js frontend and a GraphQL API layer.
* Elixir Microservices:
* Built with the Phoenix framework.
* Handle specific domains (e.g., call handling, agent management, reporting).
* Integrate with FreeSWITCH (via mod_sofia or ESL) and potentially Kamailio for
SIP routing.
* Communicate via appropriate patterns (e.g., REST, GraphQL, message queues).
* Next.js Frontend:
* Provides the user interface for agents, administrators.
* Interacts with Elixir microservices via GraphQL or REST APIs.
* GraphQL API Layer (Optional):
* Can serve as a unified interface between the frontend and various backend
microservices.
4. Technology Stack
4.1 LLMs and Model Orchestration
* Core LLMs:
* Qwen 3-32B (Alibaba Cloud / Nebius AI Studio): Initial code generation
(Perl/PHP to Elixir).
* GLM-4-32B (Zhipu AI / Hugging Face): Refactoring Elixir code.
* Llama 3.1 70B (Meta / Nebius / OVH / Groq): Fallback/optional model for open-
source coding tasks and deep refinement.
* Gemini Pro 2.5 (Google Vertex AI / Nebius AI Studio): Bug scanning, large
context window tasks.
* Claude Sonnet 4 / Opus (Anthropic): Final code polish and review.
* Orchestration Engine:
* LangChain:
* PromptTemplate: Define reusable prompt formats for each LLM.
* RunnableSequence (or LLMChain): Chain multiple LLMs and processing steps.
* ConversationBufferMemory: Maintain context between LLM calls.
* Ollama / ChatOpenAI (or equivalent) wrappers: Connect to LLM APIs (Nebius,
Groq, etc.).
* StrOutputParser / Custom Output Parsers: Clean and structure LLM output.
* Callbacks: Log metrics, errors, and evaluations (e.g., to PromptLayer).
* IDE Integration:
* Continue.dev: VS Code plugin for in-editor prompting, context awareness
(current file, repo structure), multi-model configuration, and custom command
execution (/codegen, /refactor, etc.).
* ~/.continue/config.json: Central configuration for Continue.dev, defining
models, API endpoints, and custom commands.
// Example snippet from ~/.continue/config.json
{
"models": [
{
"title": "Qwen 3-32B",
"provider": "openai", // Uses OpenAI-compatible API structure
"model": "qwen3-32b",
"apiBase": "https://api.nebius.ai/v1/inference",
"apiKey": "your-nebius-api-key", // Store securely
"contextLength": 128000,
"roles": ["chat", "code"]
}
// ... other models (GLM, Llama, Gemini, Claude)
],
"customCommands": [
{
"name": "/codegen",
"description": "Use Qwen 3-32B to generate Elixir code from Perl/PHP"
}
// ... other commands
],
"systemMessage": "You are a senior Elixir developer working on converting legacy
voice platforms (VICIdial, FreeSWITCH) to modern microservices."
* }
* Prompt Management & Evaluation:
* PromptLayer:
* Store and version control prompt templates.
* A/B testing of different prompts or models.
* Observability: Track cost, latency, error rates for LLM calls.
* Dataset Management: Store input-output pairs for benchmarking.
* Visualizing and managing multi-step prompt chains.
* Script check_promptlayer_metrics.py validates these metrics against
thresholds.
4.2 Code Validation & Quality Control
* Custom Validation Script:
* validate_elixir_code.py: Validates generated Elixir code against requirements
defined in project_specs.json. Checks for FreeSWITCH usage, Logger implementation,
Phoenix best practices, code conciseness, and concurrency patterns.
* test_validate_elixir_code.py: Unit tests for the validator itself.
* Gemini-based Evaluator:
* evaluate_output_with_gemini.py: Uses Gemini Pro 2.5 to provide a more nuanced
grading of LLM-generated code on formatting, idiomatic style, FreeSWITCH
integration accuracy, readability, and Kubernetes compatibility.
* Elixir Static Analysis & Linters:
* Credo: Enforces Elixir style guidelines and best practices.
* Dialyzer / Dialyxir: Performs static type inference and bug detection.
* Sobelow: Security-focused static analysis for Phoenix applications (detects
common vulnerabilities like XSS, SQLi, RCE).
* Frontend Validation:
* Jest: JavaScript testing framework.
* ESLint: Pluggable and configurable linter for JavaScript/Next.js.
* Prettier: Opinionated code formatter.
* General Quality & Security:
* SonarQube (with custom Elixir Plugin): Centralized dashboard for code quality,
security vulnerabilities, and test coverage.
* CodeQL: Deep semantic code analysis for security vulnerabilities and logic
errors.
* Unit Testing:
* ExUnit: Built-in Elixir testing framework.
4.3 RAG and Knowledge Management
* Knowledge Graph Backend:
* Memgraph DBMS: Stores code chunks from legacy systems (VICIdial, FreeSWITCH),
documentation, project specifications, and their relationships as a graph.
* GraphRAG Indexing: LangChain's MemgraphVectorStore with HuggingFaceEmbeddings
(e.g., all-MiniLM-L6-v2) is used to index and retrieve relevant sections from
VICIdial, FreeSWITCH, SignalWire docs.
* The setup_rag.py script can simulate chunking and indexing VICIdial code.
* Querying:
* Natural Language Query Parser: Qwen 3 (or another capable LLM) translates
natural language queries (e.g., "Show me all functions related to agent login in
VICIdial") into Cypher queries for Memgraph.
* The query_parser_prompt template is used for this translation.
* Caching:
* Redis Cache: Caches results of frequent Memgraph queries to improve
performance and reduce load on Memgraph.
* Project Specification File (:
* A critical JSON file detailing requirements for microservices, such as
FreeSWITCH/Kamailio integration, logging, database targets, etc. This file is
loaded by the orchestrator and validator.
// Example: specs/project_specs.json
{
"free_switch_required": true,
"kamailio_required": false,
"max_concurrent_calls": 1000,
"logging_mandatory": true,
"target_db": "PostgreSQL",
"microservice_type": "call_handling",
"microservices": [ // As used by validate_elixir_code.py v2
{
"name": "call_service",
"requirements": [
"Use FreeSWITCH mod_sofia",
"Implement error handling with Logger",
"Phoenix best practices",
"Concurrency support required"
]
}
]
* }
4.4 Infrastructure and Deployment
* Version Control & CI/CD Hub:
* GitLab:
* Git Repositories: Store legacy code, generated Elixir microservices,
Next.js frontend, docs, specs.
* Docs & Manuals: VICIdial Manager Manual, SignalWire Docs, FreeSWITCH
Cookbook.
* CI/CD Pipelines (.gitlab-ci.yml): Automate linting, testing, scanning,
building, and deployment.
* DVC Integration (Data Version Control): Track datasets, model weights, and
configurations if fine-tuning becomes part of the pipeline.
* Containerization:
* Docker: Elixir/Phoenix microservices and Next.js frontend are containerized.
* elixir/Dockerfile: Multi-stage build for Phoenix releases.
* nextjs/Dockerfile: Multi-stage build for Next.js, potentially served with
Nginx.
* Orchestration & Environments:
* Kubernetes (K8s): Used for deploying and managing containerized applications
in Dev_1, Dev_2, and Prod environments.
* Azure AKS is mentioned as a production Kubernetes cluster.
* Nebius/OVH can be used for GPU nodes for self-hosted LLMs (e.g., Llama 3.1 70B
using the Helm chart).
* Deployment Strategy:
* ArgoCD: GitOps-style deployments to Kubernetes environments. Changes in Git
are automatically synced to the cluster.
* Canary deployments are suggested for production rollouts.
* Database Schema Migration:
* Flyway / Liquibase: Manage and version control database schema changes for
PostgreSQL, MemSQL, ClickHouse, etc.
* Security Scanning (Infrastructure):
* Trivy: Scans Docker images for vulnerabilities.
* Cloud Providers:
* Nebius AI Studio: Inference APIs for Qwen, Llama, Gemini.
* Google Vertex AI: Access to Gemini Pro 2.5.
* Anthropic API: Access to Claude Sonnet 4.
* Hugging Face Endpoints: Host GLM-4-32B or fine-tuned models.
* OVH / Equinix Bare Metal: Future hosting of self-hosted LLMs and databases.
* Azure AKS: Production Kubernetes cluster.
* GitLab Shared Runners: CI/CD execution environment.
4.5 Monitoring and Observability
* Metrics Collection:
* Prometheus: Collects metrics on LLM performance (via
promptlayer_metrics_exporter.py or direct LLM client instrumentation), Kubernetes
health, application performance.
* prometheus.yml: Configures scrape targets, including the custom metrics
exporter.
* Visualization:
* Grafana: Visualizes metrics collected by Prometheus through dashboards
(latency, throughput, error rates, cost, validation scores).
* grafana_llm_dashboard.json: An importable dashboard definition for LLM and
code validation metrics.
* Log Aggregation:
* Loki: Centralized log aggregation for all microservices, LLM orchestrator, and
CI/CD jobs.
* Distributed Tracing:
* Tempo: Traces requests across microservices and potentially LLM calls to
understand latency and dependencies.
* LLM-Specific Observability:
* LangKit (or custom metrics via PromptLayer): Track LLM-specific metrics like
cost, latency per token, success rate per prompt/model.
* promptlayer_metrics_exporter.py: Exposes PromptLayer metrics to Prometheus.
* export_to_prometheus.py: Exports scores from test_llama_impact.py to
Prometheus.
5. Data Flow and Integration Points
1. Developer Input: Prompts and code selections from VS Code (Continue.dev) are
sent to the LangChain orchestrator.
2. Contextual Data:
* LangChain fetches project_specs.json.
* LangChain queries Memgraph (RAG) for relevant code snippets and documentation
from GitLab-mirrored content.
3. LLM Chain Processing: Data (code, context, specs) flows sequentially through
Qwen, GLM, (Llama), Gemini, Claude. Each LLM's output becomes the input for the
next.
4. Feedback Loop: Validation results (validate_elixir_code.py, Gemini evaluation)
and PromptLayer metrics can inform prompt adjustments or model choices.
5. Version Control: Generated/refined code is committed to GitLab.
6. CI/CD Trigger: GitLab CI pipeline is triggered on commits/merges.
* Pulls code from GitLab.
* Runs linters, tests, scanners (Credo, Dialyzer, Sobelow, ExUnit, SonarQube,
CodeQL).
* Builds Docker images.
7. Deployment: ArgoCD deploys Docker images to Kubernetes based on Git state.
8. Monitoring Data:
* Applications and K8s components send metrics to Prometheus.
* Logs are sent to Loki.
* Traces are sent to Tempo.
* PromptLayer sends data to its platform and can be scraped by
promptlayer_metrics_exporter.py.
6. Security Architecture
* API Key Management: Secure storage and access control for LLM API keys (e.g.,
GitLab CI variables, Kubernetes secrets, HashiCorp Vault). NEBIUS_API_KEY,
GROQ_API_KEY, PROMPTLAYER_API_KEY, etc., must be protected.
* Code Security (Static Analysis):
* Sobelow: For Phoenix-specific vulnerabilities.
* SonarQube: Broader static analysis for quality and security.
* CodeQL: Deep security analysis.
* * Container Security:
* Trivy: Docker image vulnerability scanning integrated into the CI/CD pipeline.
* Minimal base images for Docker containers.
* Regular updates of base images and dependencies.
* Infrastructure Security:
* Secure Kubernetes cluster configuration (e.g., RBAC, network policies).
* Secrets management within Kubernetes.
* Data Security:
* Ensure sensitive data from legacy systems is handled appropriately during RAG
indexing and LLM processing.
* Consider data masking or anonymization if necessary.
* Prompt Security:
* Be aware of prompt injection risks if user-supplied input directly forms part
of LLM prompts. Sanitize or structure inputs carefully.
7. Scalability and Performance Considerations
* LLM Inference:
* Utilize scalable cloud provider APIs (Nebius, Vertex AI, Anthropic).
* For self-hosted Llama 3.1 70B, use GPU-enabled nodes on Nebius/OVH and tools
like vLLM (via Helm chart) for optimized inference.
* Horizontal Pod Autoscaler (HPA) for self-hosted LLM inference services in
Kubernetes.
* Microservices:
* Elixir/Phoenix applications are inherently scalable due to the BEAM VM.
* Kubernetes HPA can scale microservices based on CPU/memory or custom metrics.
* RAG System (Memgraph):
* Optimize Cypher queries.
* Use Redis caching for frequent RAG queries.
* Scale Memgraph instance as needed.
* CI/CD Pipeline:
* Utilize GitLab shared or self-hosted runners with sufficient capacity.
* Parallelize CI/CD stages where possible.
* Databases:
* Choose appropriate instance sizes and configurations for PostgreSQL,
ClickHouse, etc.
* Implement read replicas or sharding if high database load is anticipated.
8. Environment Setup (dev_1, dev_2, prod)
The pipeline supports multiple isolated environments deployed on Kubernetes:
* (Development Environment 1):
* Purpose: Quick feedback loop for developers, initial integration testing of
LLM-generated code.
* Deployment: Automated via CI/CD on every feature branch commit.
* Resources: May use smaller resource allocations, local or shared dev
databases.
* (Staging/Pre-production Environment):
* Purpose: More thorough testing, UAT, performance testing, and integration with
other services.
* Deployment: Manual trigger from CI/CD after dev_1 tests pass (e.g., on merge
to a staging branch).
* Resources: Closer to production scale, may use dedicated staging databases.
* (Production Environment):
* Purpose: Live user-facing environment.
* Deployment: Manual trigger from CI/CD, often with additional approvals. Canary
deployment strategy recommended.
* Resources: Full production scale, robust monitoring, alerting, and backup
procedures.
Kubernetes Manifests:
Specific Kubernetes deployment (deployment.yaml) and service (service.yaml)
manifests are maintained for each environment (e.g., in k8s/dev_1/, k8s/dev_2/,
k8s/prod/). These define environment-specific configurations like replica counts,
resource limits, config maps, and secrets. ArgoCD can manage the synchronization of
these manifests from Git to the respective Kubernetes namespaces.
# Example: k8s/dev_1/deployment.yaml for an Elixir service
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-elixir-service-dev1
namespace: dev1 # Assuming a namespace per environment
spec:
replicas: 1 # Fewer replicas for dev
selector:
matchLabels:
app: my-elixir-service
environment: dev1
template:
metadata:
labels:
app: my-elixir-service
environment: dev1
spec:
containers:
- name: elixir-app
image: your-registry/my-elixir-service:latest # Or feature-branch
specific tag
ports:
- containerPort: 4000
env:
- name: MIX_ENV
value: "dev"
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: dev1-db-secret
key: database_url
# Other environment-specific variables
________________
**tasks.md**
```markdown
# LLM Pipeline Implementation Tasks
This document provides a step-by-step guide for setting up, configuring, and
operating the LLM-powered microservices refactoring pipeline.
# if __name__ == "__main__":
7. # chunk_and_index_vicidial_code("/path/to/your/vicidial/code")
8. Run it: python scripts/setup_rag.py (after customization).
9. Verify Memgraph Connection in Orchestrator:
The query_memgraph function in llm_orchestrator_with_context.py attempts to connect
to Memgraph. Ensure host/port are correct if not using defaults.
Phase 3: Code Generation Pipeline Execution
Task 3.1: Run the Orchestration Script
1. Define a task and (optionally) specific specs.
# Example usage within llm_orchestrator_with_context.py or a calling script
# if __name__ == "__main__":
# task = "Rewrite AST_server.pl agent login sequence to an Elixir Phoenix
controller action using FreeSWITCH for call control."
# specs_override = { # Overrides specs from project_specs.json for this run
# "free_switch_required": True,
# "kamailio_required": False,
# "microservices": [{
# "name": "agent_auth_service",
# "requirements": ["Use FreeSWITCH mod_sofia for agent phone
registration check", "Implement error handling with Logger"]
# }]
# }
# result = orchestrate_code_generation(task, specs=specs_override)
2. # # Process result...
3. Execute the script:
# Ensure API keys and PROJECT_SPECS_PATH are set
4. python scripts/llm_orchestrator_with_context.py
5. Observe llm_orchestrator.log for detailed step-by-step logging.
6. Review the generated initial_code, refined_code, bug_report,
final_review, and final_code in the output.
Task 3.2: Iterative Refinement with Continue.dev
After the orchestrator produces initial code:
1. Open the generated Elixir files in VS Code.
2. Use Continue.dev commands (/refactor, /scanbugs, /review, or custom
prompts) to further refine specific sections of the code with different LLMs as
configured in ~/.continue/config.json.
3. For example, highlight a complex Elixir function, type /explain to get
Llama 3.1's explanation, or /refactor to have GLM-4 improve it.
Phase 4: Code Validation and Quality Control Setup
Task 4.1: Implement Custom Code Validator
1. Place scripts/validate_elixir_code.py and
scripts/test_validate_elixir_code.py in your project.
2. The validator script checks against project_specs.json. Ensure this
file accurately reflects your requirements.
3. Run validator tests:
python -m pytest scripts/test_validate_elixir_code.py -v
4. # Or: python scripts/test_validate_elixir_code.py
5. Integrate validate_elixir_code(final_code, specs) call at the end of
your llm_orchestrator_with_context.py or as a separate CI step.
Task 4.2: Set Up Gemini-based Evaluator
1. Place scripts/evaluate_output_with_gemini.py in your project.
2. Ensure NEBIUS_API_KEY is available for Gemini Pro 2.5 access.
3. This script can be run on LLM-generated code to get a quality score.
# Example: You'd call this from another script or CI
4. # python scripts/evaluate_output_with_gemini.py --codefile
path/to/generated_code.ex --specfile specs/project_specs.json
5. The provided script has an if __name__ == "__main__": block for
standalone testing.
Task 4.3: Integrate Static Analysis Tools
For an Elixir project:
1. Credo:
* Add to mix.exs: {:credo, "~> 1.7", only: [:dev, :test], runtime: false}
* Run: mix deps.get, then mix credo --strict
2. Dialyxir:
* Add to mix.exs: {:dialyxir, "~> 1.4", only: [:dev, :test], runtime:
false}
* Run: mix deps.get, then mix dialyzer (may require mix dialyzer.plt)
3. Sobelow:
* Add to mix.exs: {:sobelow, "~> 0.13.0", only: [:dev, :test], runtime:
false}
* Run: mix deps.get, then mix sobelow --config
For Next.js frontend:
4. ESLint & Prettier:
* Install: npm install --save-dev eslint eslint-config-next prettier
eslint-plugin-prettier eslint-config-prettier
* Configure .eslintrc.json and .prettierrc.json.
* Run: npx eslint ., npx prettier --check .
Phase 5: Pipeline CI/CD Configuration and Deployment
Task 5.1: Configure GitLab CI/CD (.gitlab-ci.yml)
1. Create/edit .gitlab-ci.yml in your project root.
2. Adapt the comprehensive example provided in LLM development
Pipeline.txt (Section: "✅ File: .gitlab-ci.yml").
* Define stages: validate, lint, test, scan, build, deploy.
* Include jobs for:
* validate_llm_output: Runs validate_elixir_code.py and potentially
evaluate_output_with_gemini.py.
* elixir_lint: Runs mix credo, mix dialyzer, mix sobelow.
* elixir_test: Runs mix test.
* javascript_lint & javascript_test for frontend.
* sonarqube_scan & codeql_scan.
* docker_build: Builds Elixir and Next.js Docker images.
* deploy_dev_1, deploy_dev_2, deploy_prod: Deploy to Kubernetes
environments.
* Ensure necessary API keys and variables (NEBIUS_API_KEY,
CI_REGISTRY_USER, CI_REGISTRY_PASSWORD, etc.) are set in GitLab CI/CD project
settings.
3. # .gitlab-ci.yml (Simplified snippet focusing on validation)
image: alpine:latest # Default image, can be overridden per job
stages:
- validate
- lint
- test
# ... other stages
before_script:
- apk add --no-cache python3 py3-pip git
- pip3 install -r requirements.txt # Assuming a requirements.txt for pipeline
scripts
validate_llm_code:
stage: validate
image: python:3.9 # Use a Python image
script:
- echo "Validating LLM generated code..."
- export PROJECT_SPECS_PATH="specs/project_specs.json" # Ensure this path is
correct in CI context
# Assume generated code is available at a known path, e.g.,
'output/generated_code.ex'
# This step might need to fetch code generated in a previous job or be part of
a larger script
# For simplicity, let's assume validate_elixir_code.py can take a file path
# python scripts/validate_elixir_code.py --codefile output/generated_code.ex --
specfile $PROJECT_SPECS_PATH
# The original document implies validate_elixir_code.py is run by
validate_llm_output job in CI
# For testing the script directly:
- python scripts/validate_elixir_code.py # This will run its __main__ if it's
designed to load sample code / make validate_elixir_code.py accept file paths
only:
- branches
- merge_requests
elixir_lint:
stage: lint
image: elixir:1.15 # Use an Elixir image
before_script: # Elixir specific setup
- mix local.hex --if-missing --force
- mix local.rebar --if-missing --force
- mix deps.get
script:
- cd elixir/ # Assuming Elixir project is in elixir/ subfolder
- mix credo --strict
- mix dialyzer
- mix sobelow --config
only:
- branches
- merge_requests
This implementation guide should provide a solid foundation for building and
operating your LLM-powered refactoring pipeline. Remember that this is an iterative
process; continuous monitoring, optimization, and learning will be key to success.