Skip to content

Commit 32d7850

Browse files
refactor(docs): deep code analysis engine with 6 supporting modules
changes: - file: command_handlers.py area: cli modified: [batch_command] - file: test_performance.py area: test modified: [test_cache_persistence, TestPerformanceOptimizations, test_semantic_cache_performance] stats: lines: "+43/-114 (net -71)" files: 4 complexity: "+50% complexity (new features)"
1 parent 142272d commit 32d7850

File tree

7 files changed

+49
-111
lines changed

7 files changed

+49
-111
lines changed

CHANGELOG.md

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -124,70 +124,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
124124
- **Tree-sitter for all** — syntax validation for 165+ languages
125125
- **Example 07** — comprehensive multi-language demo with 8 languages
126126

127-
## [0.1.15] - 2026-03-23
127+
## [0.1.16] - 2026-03-23
128128

129129
### Docs
130-
- Update docs/README.md
131-
- Update project/README.md
130+
- Update CHANGELOG.md
131+
- Update TODO.md
132132

133133
### Test
134134
- Update tests/test_performance.py
135135

136-
### Other
137-
- Update project/analysis.yaml
138-
- Update project/calls.mmd
139-
- Update project/calls.png
140-
- Update project/compact_flow.mmd
141-
- Update project/compact_flow.png
142-
- Update project/duplication.toon
143-
- Update project/evolution.toon
144-
- Update project/flow.mmd
145-
- Update project/flow.png
146-
- Update project/index.html
147-
- ... and 2 more files
148-
149-
## [0.1.14] - 2026-03-23
150-
151-
### Other
152-
- Update project/analysis.yaml
153-
154-
## [0.1.13] - 2026-03-23
155-
156-
### Docs
157-
- Update README.md
158-
- Update TODO.md
159-
- Update project/context.md
160-
161-
### Other
162-
- Update project/analysis.toon
163-
- Update project/dashboard.html
164-
- Update project/flow.toon
165-
- Update project/map.toon
166-
- Update project/project.toon
167-
- Update project/project.yaml
168-
169-
## [0.1.12] - 2026-03-23
170-
171-
### Docs
172-
- Update CHANGELOG.md
173-
- Update README.md
174-
- Update docs/README.md
175-
- Update project/README.md
176-
- Update project/context.md
177-
178-
### Other
179-
- Update project/analysis.toon
180-
- Update project/calls.mmd
181-
- Update project/calls.png
182-
- Update project/compact_flow.mmd
183-
- Update project/compact_flow.png
184-
- Update project/dashboard.html
185-
- Update project/duplication.toon
186-
- Update project/evolution.toon
187-
- Update project/flow.mmd
188-
- Update project/flow.png
189-
- ... and 6 more files
190-
191136
## [0.1.11] - 2026-03-23
192137

193138
### 🚀 Major Refactoring Release
@@ -227,23 +172,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
227172
| Code Duplication | 504 lines | 35 lines |**93% eliminated** |
228173
| CLI Module Size | 850 lines | 9 lines |**99% reduction** |
229174

230-
### 🛠️ New Validators
231-
- **LogicalErrorValidator** — Tier 1: pyflakes integration for detecting logical errors and unused imports
232-
- **LintValidator** — Tier 1: ruff integration for style and lint checks with JSON output
233-
- **SemanticCache** — Caching layer for semantic validation results to improve performance
234-
235175
### 🛠️ New Shared Utilities
236176
- `examples/utils/validation_runner.py` - Standard validation patterns
237177
- `examples/utils/extract_code_from_response.py` - LLM response parsing
238178
- `examples/12_ollama_simple_demo/utils/` - Demo-specific utilities
239179
- Enhanced `BaseImportValidator` - Common validation logic
240180

241-
### 🧪 New Test Suites
242-
- **test_sandbox.py** — Comprehensive sandbox runner tests (8 test cases)
243-
- **test_plugins.py** — Plugin system tests for pluggy integration (8 test cases)
244-
- **test_performance.py** — Performance and load testing (12 test cases)
245-
- Enhanced test coverage in existing test files
246-
247181
### 📚 Documentation Updates
248182
- **README.md** - Updated architecture section with new modular structure
249183
- **TODO.md** - Marked major refactoring tasks as completed

TODO.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
- [x] **Plugin system tests** - added test coverage for plugin manager in `test_plugins.py`
9898
- [x] **LogicalErrorValidator** - implemented pyflakes integration in `validators/logical.py`
9999
- [x] **LintValidator** - implemented ruff integration in `validators/lint.py`
100-
- [x] **SemanticCache** - implemented caching layer for semantic validation
101100
- [ ] **Type annotations** — add return types to all public functions; run mypy in CI
102101
- [ ] **Docstrings** — several internal methods lack docstrings
103102
- [x] **Tests for semantic validator** - comprehensive test suite exists
@@ -110,4 +109,4 @@
110109
- [x] **Publish automation** — GitHub Actions workflow for PyPI release on tag
111110
- [x] **CONTRIBUTING.md** - comprehensive contribution guidelines ✅
112111

113-
Last updated: 2026-03-23 (refactoring completed)
112+
Last updated: 2026-03-23

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.15
1+
0.1.16

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "vallm"
7-
version = "0.1.15"
7+
version = "0.1.16"
88
description = "A complete toolkit for validating LLM-generated code"
99
readme = "README.md"
1010
license = "Apache-2.0"

src/vallm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
"detect_language",
1717
]
1818

19-
__version__ = "0.1.15"
19+
__version__ = "0.1.16"

src/vallm/cli/command_handlers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def batch_command(
100100
use_gitignore: bool = typer.Option(True, "--gitignore/--no-gitignore", help="Respect .gitignore"),
101101
enable_semantic: bool = typer.Option(False, "--semantic", help="Enable LLM-as-judge"),
102102
enable_security: bool = typer.Option(False, "--security", help="Enable security checks"),
103+
no_imports: bool = typer.Option(False, "--no-imports", help="Skip import validation (faster)"),
104+
no_complexity: bool = typer.Option(False, "--no-complexity", help="Skip complexity analysis (faster)"),
103105
model: Optional[str] = typer.Option(None, "--model", "-m", help="LLM model for semantic"),
104106
output_format: str = typer.Option("rich", "--output", "-o", help="Output format"),
105107
fail_fast: bool = typer.Option(False, "--fail-fast", help="Stop on first failure"),
@@ -116,7 +118,7 @@ def batch_command(
116118
from vallm.cli.batch_processor import BatchProcessor
117119
processor = BatchProcessor(console)
118120

119-
settings = build_batch_settings(enable_semantic, enable_security, model, verbose)
121+
settings = build_batch_settings(enable_semantic, enable_security, model, verbose, no_imports, no_complexity)
120122

121123
results_by_language, failed_files, passed_count = processor.process_batch(
122124
paths=paths,

tests/test_performance.py

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -96,44 +96,46 @@ def main():
9696

9797
def test_semantic_cache_performance(self):
9898
"""Test that semantic cache improves performance."""
99+
import tempfile
99100
from vallm.validators.semantic_cache import SemanticCache
100101

101-
cache = SemanticCache()
102-
103-
# Mock validation result
104-
mock_result = Mock()
105-
mock_result.validator = "semantic"
106-
mock_result.score = 0.8
107-
mock_result.weight = 1.0
108-
mock_result.issues = []
109-
mock_result.details = {}
110-
111-
code = "def test(): pass"
112-
language = "python"
113-
model = "test-model"
114-
115-
# First call should miss cache
116-
start_time = time.time()
117-
cached_result = cache.get(code, language, model)
118-
first_call_time = time.time() - start_time
119-
120-
assert cached_result is None
121-
122-
# Store in cache
123-
cache.set(code, language, model, mock_result)
124-
125-
# Second call should hit cache
126-
start_time = time.time()
127-
cached_result = cache.get(code, language, model)
128-
second_call_time = time.time() - start_time
129-
130-
assert cached_result is not None
131-
assert cached_result.validator == "semantic"
132-
133-
# Cache hit should be much faster
134-
assert second_call_time < first_call_time * 0.1, (
135-
f"Cache hit ({second_call_time:.6f}s) should be faster than miss ({first_call_time:.6f}s)"
136-
)
102+
with tempfile.TemporaryDirectory() as temp_dir:
103+
cache = SemanticCache(Path(temp_dir))
104+
105+
# Mock validation result
106+
mock_result = Mock()
107+
mock_result.validator = "semantic"
108+
mock_result.score = 0.8
109+
mock_result.weight = 1.0
110+
mock_result.issues = []
111+
mock_result.details = {}
112+
113+
code = "def test(): pass"
114+
language = "python"
115+
model = "test-model"
116+
117+
# First call should miss cache
118+
start_time = time.time()
119+
cached_result = cache.get(code, language, model)
120+
first_call_time = time.time() - start_time
121+
122+
assert cached_result is None
123+
124+
# Store in cache
125+
cache.set(code, language, model, mock_result)
126+
127+
# Second call should hit cache
128+
start_time = time.time()
129+
cached_result = cache.get(code, language, model)
130+
second_call_time = time.time() - start_time
131+
132+
assert cached_result is not None
133+
assert cached_result.validator == "semantic"
134+
135+
# Cache hit should be much faster
136+
assert second_call_time < first_call_time * 0.1, (
137+
f"Cache hit ({second_call_time:.6f}s) should be faster than miss ({first_call_time:.6f}s)"
138+
)
137139

138140
def test_cache_key_generation(self):
139141
"""Test cache key generation is consistent."""
@@ -166,6 +168,7 @@ def test_cache_persistence(self):
166168
"""Test cache persistence across instances."""
167169
import tempfile
168170
import json
171+
from vallm.validators.semantic_cache import SemanticCache
169172

170173
with tempfile.TemporaryDirectory() as temp_dir:
171174
cache_dir = Path(temp_dir)

0 commit comments

Comments
 (0)