Skip to content

Commit 58b5533

Browse files
examples
1 parent e283223 commit 58b5533

30 files changed

+18771
-649
lines changed

Dockerfile.test

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Multi-stage Dockerfile for vallm testing across different systems
2+
3+
# Stage 1: Ubuntu 22.04
4+
FROM ubuntu:22.04 AS ubuntu-22
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
RUN apt-get update && apt-get install -y \
7+
python3.11 \
8+
python3.11-pip \
9+
python3.11-venv \
10+
python3.11-dev \
11+
git \
12+
curl \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
WORKDIR /app
16+
COPY . .
17+
RUN python3.11 -m venv /opt/venv
18+
RUN . /opt/venv/bin/activate && pip install -e .[all]
19+
RUN . /opt/venv/bin/activate && vallm --help
20+
RUN . /opt/venv/bin/activate && vallm info
21+
22+
# Stage 2: Ubuntu 24.04
23+
FROM ubuntu:24.04 AS ubuntu-24
24+
ENV DEBIAN_FRONTEND=noninteractive
25+
RUN apt-get update && apt-get install -y \
26+
python3.12 \
27+
python3.12-pip \
28+
python3.12-venv \
29+
python3.12-dev \
30+
git \
31+
curl \
32+
&& rm -rf /var/lib/apt/lists/*
33+
34+
WORKDIR /app
35+
COPY . .
36+
RUN python3.12 -m venv /opt/venv
37+
RUN . /opt/venv/bin/activate && pip install -e .[all]
38+
RUN . /opt/venv/bin/activate && vallm --help
39+
RUN . /opt/venv/bin/activate && vallm info
40+
41+
# Stage 3: Debian 12 (Bookworm)
42+
FROM debian:bookworm AS debian-12
43+
ENV DEBIAN_FRONTEND=noninteractive
44+
RUN apt-get update && apt-get install -y \
45+
python3.11 \
46+
python3-pip \
47+
python3-venv \
48+
python3-dev \
49+
git \
50+
curl \
51+
&& rm -rf /var/lib/apt/lists/*
52+
53+
WORKDIR /app
54+
COPY . .
55+
RUN python3 -m venv /opt/venv
56+
RUN . /opt/venv/bin/activate && pip install -e .[all]
57+
RUN . /opt/venv/bin/activate && vallm --help
58+
RUN . /opt/venv/bin/activate && vallm info
59+
60+
# Stage 4: Alpine Linux
61+
FROM alpine:3.19 AS alpine
62+
RUN apk add --no-cache \
63+
python3-dev \
64+
py3-pip \
65+
py3-virtualenv \
66+
git \
67+
curl \
68+
gcc \
69+
musl-dev \
70+
linux-headers
71+
72+
WORKDIR /app
73+
COPY . .
74+
RUN python3 -m venv /opt/venv
75+
RUN . /opt/venv/bin/activate && pip install -e .[all]
76+
RUN . /opt/venv/bin/activate && vallm --help
77+
RUN . /opt/venv/bin/activate && vallm info
78+
79+
# Stage 5: Fedora 39
80+
FROM fedora:39 AS fedora-39
81+
RUN dnf install -y \
82+
python3.11 \
83+
python3-pip \
84+
python3-devel \
85+
git \
86+
curl \
87+
&& dnf clean all
88+
89+
WORKDIR /app
90+
COPY . .
91+
RUN python3.11 -m venv /opt/venv
92+
RUN . /opt/venv/bin/activate && pip install -e .[all]
93+
RUN . /opt/venv/bin/activate && vallm --help
94+
RUN . /opt/venv/bin/activate && vallm info
95+
96+
# Stage 6: CentOS Stream 9
97+
FROM quay.io/centos/centos:stream9 AS centos-9
98+
RUN dnf install -y \
99+
python3.9 \
100+
python3-pip \
101+
python3-devel \
102+
git \
103+
curl \
104+
&& dnf clean all
105+
106+
WORKDIR /app
107+
COPY . .
108+
RUN python3.9 -m venv /opt/venv
109+
RUN . /opt/venv/bin/activate && pip install -e .[all]
110+
RUN . /opt/venv/bin/activate && vallm --help
111+
RUN . /opt/venv/bin/activate && vallm info
112+
113+
# Stage 7: Python Slim (Debian-based)
114+
FROM python:3.11-slim AS python-slim
115+
RUN apt-get update && apt-get install -y \
116+
git \
117+
curl \
118+
&& rm -rf /var/lib/apt/lists/*
119+
120+
WORKDIR /app
121+
COPY . .
122+
RUN pip install -e .[all]
123+
RUN vallm --help
124+
RUN vallm info
125+
126+
# Stage 8: Python Alpine
127+
FROM python:3.11-alpine AS python-alpine
128+
RUN apk add --no-cache \
129+
git \
130+
curl \
131+
gcc \
132+
musl-dev
133+
134+
WORKDIR /app
135+
COPY . .
136+
RUN pip install -e .[all]
137+
RUN vallm --help
138+
RUN vallm info

README.md

Lines changed: 80 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ vallm validates code proposals through a **four-tier pipeline** — from millise
4242

4343
| Language | Syntax | Imports | Complexity | Security |
4444
|----------|--------|---------|------------|----------|
45-
| Python | ✅ AST + tree-sitter | ✅ Full resolution | ✅ radon + lizard | ✅ bandit + patterns |
45+
| Python | ✅ AST + tree-sitter | ✅ Full resolution (22 methods) | ✅ radon + lizard | ✅ bandit + patterns |
4646
| JavaScript | ✅ tree-sitter | ✅ Node.js builtins | ✅ lizard | ✅ XSS, eval patterns |
4747
| TypeScript | ✅ tree-sitter | ✅ Node.js builtins | ✅ lizard | ✅ XSS, eval patterns |
4848
| Go | ✅ tree-sitter | ✅ stdlib + modules | ✅ lizard | ✅ SQL injection, exec |
@@ -73,6 +73,20 @@ pip install vallm[graph] # NetworkX graph analysis
7373

7474
## Quick Start
7575

76+
### Validate Entire Project
77+
78+
```bash
79+
# Install with LLM support
80+
pip install vallm[llm]
81+
82+
# Setup Ollama (for semantic review)
83+
ollama pull qwen2.5-coder:7b
84+
ollama serve
85+
86+
# Validate entire project recursively
87+
vallm batch . --recursive --semantic --model qwen2.5-coder:7b
88+
```
89+
7690
### Python API
7791

7892
```python
@@ -94,22 +108,23 @@ print(f"Verdict: {result.verdict.value}") # pass / review / fail
94108
print(f"Score: {result.weighted_score:.2f}")
95109
```
96110

97-
### CLI
111+
### CLI Commands Reference
98112

99113
```bash
100-
# Validate a file
101-
vallm validate --file mycode.py
102-
103-
# Quick syntax check
104-
vallm check mycode.py
114+
# Batch validation (best for entire projects)
115+
vallm batch . --recursive --semantic --model qwen2.5-coder:7b
116+
vallm batch src/ --recursive --include "*.py,*.js" --exclude "*/test/*"
117+
vallm batch . --recursive --format json --fail-fast
105118

106-
# With LLM semantic review (requires Ollama)
119+
# Single file validation
107120
vallm validate --file mycode.py --semantic --model qwen2.5-coder:7b
121+
vallm validate --file app.js --security
108122

109-
# JSON output
110-
vallm validate --file mycode.py --format json
123+
# Quick syntax check only
124+
vallm check mycode.py
125+
vallm check src/main.go
111126

112-
# Show config and available validators
127+
# Configuration and info
113128
vallm info
114129
```
115130

@@ -253,31 +268,67 @@ cd examples && ./run.sh
253268
| `05_llm_semantic_review/` | Ollama Qwen 2.5 Coder 7B LLM-as-judge review |
254269
| `06_multilang_validation/` | JavaScript and C validation via tree-sitter |
255270
| `07_multi_language/` | **Comprehensive multi-language support** — 8+ languages with auto-detection |
271+
| `08_code2llm_integration/` | Project analysis integration with code2llm |
272+
| `09_code2logic_integration/` | Call graph analysis with code2logic |
273+
| `10_mcp_ollama_demo/` | MCP (Model Context Protocol) demo with Ollama |
274+
| `11_claude_code_autonomous/` | Autonomous refactoring with Claude Code |
275+
| `12_ollama_simple_demo/` | Simplified Ollama integration example |
256276

257277
## Architecture
258278

259279
```
260280
src/vallm/
261-
├── cli.py # Typer CLI: validate, check, info, batch
262-
├── config.py # pydantic-settings (VALLM_* env vars)
263-
├── hookspecs.py # pluggy hook specifications
264-
├── scoring.py # Weighted scoring + verdict engine
281+
├── cli.py # Typer CLI (401L, 8 methods, CC=42) - needs refactoring
282+
├── config.py # pydantic-settings (VALLM_* env vars)
283+
├── hookspecs.py # pluggy hook specifications
284+
├── scoring.py # Weighted scoring + verdict engine (CC=18 validate function)
265285
├── core/
266-
│ ├── languages.py # Language enum, auto-detection, 30+ languages
267-
│ ├── proposal.py # Proposal model
268-
│ ├── ast_compare.py # tree-sitter + Python AST similarity
269-
│ ├── graph_builder.py # Import/call graph construction
270-
│ └── graph_diff.py # Before/after graph comparison
286+
│ ├── languages.py # Language enum, auto-detection, 30+ languages
287+
│ ├── proposal.py # Proposal model
288+
│ ├── ast_compare.py # tree-sitter + Python AST similarity
289+
│ ├── graph_builder.py # Import/call graph construction
290+
│ └── graph_diff.py # Before/after graph comparison
271291
├── validators/
272-
│ ├── syntax.py # Tier 1: ast.parse + tree-sitter (multi-lang)
273-
│ ├── imports.py # Tier 1: module resolution (Python)
274-
│ ├── complexity.py # Tier 2: radon (Python) + lizard (16+ langs)
275-
│ ├── security.py # Tier 2: patterns + bandit
276-
│ └── semantic.py # Tier 3: LLM-as-judge
292+
│ ├── syntax.py # Tier 1: ast.parse + tree-sitter (multi-lang)
293+
│ ├── imports.py # Tier 1: module resolution (653L, 22 methods) - god module
294+
│ ├── complexity.py # Tier 2: radon (Python) + lizard (16+ langs)
295+
│ ├── security.py # Tier 2: patterns + bandit
296+
│ └── semantic.py # Tier 3: LLM-as-judge
277297
└── sandbox/
278-
└── runner.py # subprocess / Docker execution
298+
└── runner.py # subprocess / Docker execution
279299
```
280300

301+
### Code Health Metrics
302+
303+
Current codebase metrics (generated by code2llm analysis):
304+
305+
| Metric | Current | Target |
306+
|--------|---------|--------|
307+
| Avg Cyclomatic Complexity (CC̄) | 3.5 | ≤2.4 |
308+
| Max CC | 42 | ≤20 |
309+
| God Modules (>500L) | 2 | 0 |
310+
| High CC Functions (≥15) | 2 | ≤1 |
311+
| Total Functions | 91 | - |
312+
| Total Classes | 19 | - |
313+
314+
**Critical Functions (CC ≥ 10)**:
315+
316+
| Function | Location | CC | Fan-out | Priority |
317+
|----------|----------|-----|---------|----------|
318+
| `batch` | `cli.py:140` | **42** | 34 | 🔴 Split immediately |
319+
| `validate` | `scoring.py:122` | **18** | 20 | 🟡 Refactor |
320+
| `_check_lizard` | `complexity.py` | 12 | 9 | 🟡 Simplify |
321+
| `_parse_response` | `semantic.py` | 12 | 17 | 🟡 Simplify |
322+
323+
**God Modules**:
324+
- `src/vallm/validators/imports.py` (653L, 22 methods, 22 dependent imports)
325+
- `src/vallm/cli.py` (401L, 8 methods, CC=42)
326+
327+
See `project/` directory for full analysis files:
328+
- `analysis.toon` - Health diagnostics and complexity metrics
329+
- `evolution.toon` - Refactoring queue with ranked priorities
330+
- `context.md` - Architecture summary for LLM assistance
331+
281332
## Roadmap
282333

283334
**v0.2 — Completeness**
@@ -286,13 +337,16 @@ src/vallm/
286337
- TOML config loading (`vallm.toml`, `[tool.vallm]`)
287338
- Pre-commit hook integration
288339
- GitHub Actions CI/CD
340+
- **Refactoring: Split `batch` function (CC=42)**
341+
- **Refactoring: Modularize `imports.py` god module**
289342

290343
**v0.3 — Depth**
291344
- AST edit distance via apted/zss
292345
- CodeBERTScore embedding similarity
293346
- NetworkX cycle detection and centrality in graph analysis
294347
- RegressionValidator (Tier 4) with pytest-json-report
295348
- TypeCheckValidator (mypy/pyright)
349+
- **Refactoring: Extract output formatters**
296350

297351
**v0.4 — Intelligence**
298352
- `--fix` auto-repair mode (LLM-based retry loop)

TODO.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
11
# TODO
22

3-
## Refactoring — reduce complexity (from analysis.toon)
3+
## Refactoring — reduce complexity (current status: 2026-03-22)
44

5-
5 functions have CC≥10 (target: max-CC ≤7, CC̄ ≤2.8):
5+
**Current Metrics (from code2llm analysis):**
6+
- CC̄ = 3.5 (target: ≤2.4)
7+
- Max CC = 42 (target: ≤20)
8+
- God modules = 2 (target: 0)
9+
- High CC (≥15) = 2 functions (target: ≤1)
10+
- Critical functions (CC≥10) = 8 functions
11+
12+
**Priority 1: Critical Functions (CC≥15)**
13+
14+
- [ ] **`cli.batch` CC=42, fan=34** — SPLIT: extract file discovery, filtering, validation loop, result aggregation, and output formatting into separate modules
15+
- [ ] **`scoring.validate` CC=18, fan=20** — REFACTOR: extract validator sorting and fail-fast execution logic
16+
17+
**Priority 2: High Complexity (CC 10-15)**
618

7-
- [ ] **`cli.validate` CC=14, fan=18** — extract settings build, proposal build, and output dispatch into separate functions
8-
- [ ] **`cli.batch` CC=high** — newly added, needs refactoring (inline: extract file filtering, result aggregation)
919
- [ ] **`SemanticValidator._parse_response` CC=12, fan=17** — split JSON extraction, score normalization, and issue parsing into 3 methods
1020
- [ ] **`ComplexityValidator._check_python_complexity` CC=11** — extract radon block analysis and MI check into helpers
1121
- [ ] **`_output_rich` CC=11, fan=8** — extract verdict panel, results table, and issues list into separate renderers
12-
- [ ] **`ImportValidator.validate` CC=11** — extract AST walking into `_extract_imports()` generator
22+
- [ ] **`ImportValidator._validate_python` CC=10, fan=13** — extract AST walking into `_extract_imports()` generator
23+
- [ ] **`cli.validate` CC=high** — extract settings build, proposal build, and output dispatch
24+
25+
**Priority 3: God Modules**
26+
27+
- [ ] **`validators/imports.py` (653L, 22 methods)** — SPLIT into language-specific submodules: python.py, javascript.py, go.py, rust.py, java.py, c_cpp.py
28+
- Risk: 22 import paths depend on this — maintain backward compatibility via `__init__.py` re-exports
29+
- [ ] **`cli.py` (401L, 8 methods, CC=42)** — SPLIT: extract output formatters to `output.py`, batch logic to `batch.py`
1330

14-
9 more functions at CC 5–10 to review after critical ones are resolved.
31+
**Priority 4: Medium Complexity (CC 5-10)** — 19 functions to review after critical ones
1532

1633
## Multi-Language Support (Completed ✓)
1734

0 commit comments

Comments
 (0)