Skip to content

refactor: harden generative compilation pipeline#71

Merged
nxank4 merged 8 commits intomainfrom
refactor/generative-compilation-hardening
Feb 27, 2026
Merged

refactor: harden generative compilation pipeline#71
nxank4 merged 8 commits intomainfrom
refactor/generative-compilation-hardening

Conversation

@nxank4
Copy link
Copy Markdown
Collaborator

@nxank4 nxank4 commented Feb 27, 2026

Summary

Hardens the LLM code-generation pipeline with better sandboxing, error handling, and developer experience.

Changes

Commit Scope
source_sanitizer.py [NEW] Strips markdown fences, prose, unicode operators from LLM output (17 tests)
sandbox.py Restricted __import__ — only explicitly allowed modules can be imported
feature_discovery.py, shredder.py Hardened retry loops: catches ValueError from compile, per-retry logging, actionable error messages with model suggestions
model_manager.py In-process cache for verified models (skips redundant Ollama API calls), fixes dict/object API response handling
LIBRARY_SUMMARY.md [DELETE] Superseded by module docstrings and examples/README.md

Design Decisions

  • Sandbox import restriction prevents LLM-generated code from importing arbitrary modules (e.g. subprocess, os). Only modules in the allowed_modules list are permitted.
  • Actionable error messages guide users towards solutions (larger model, more retries) instead of opaque "code generation failed" errors.
  • Model verification cache eliminates repeated ollama list calls within the same process, useful for batch pipelines.

Tests

42 tests across test_source_sanitizer.py, test_sandbox.py, test_model_manager.py.

uv run pytest tests/unit/utils/ tests/unit/inference/ -v --no-cov

…eAuditor

- TrapPruner: statistical profiling + LLM verification of Gaussian noise columns
- MissingnessRecognizer: MNAR pattern detection with sandbox-compiled encoders
- TargetLeakageAuditor: semantic timeline evaluation for target leakage
…o public API

- Add all three to extraction/__init__.py lazy imports
- Add Loclean class methods + module-level convenience functions
- Update __all__ in loclean/__init__.py
…r, TargetLeakageAuditor

- 13 tests each (39 total) covering profiling, prompt construction,
  verdict parsing, verification, and mock-LLM integration
- Strip markdown fences, prose, and backticks
- Fix unicode operators and invalid numeric literals
- 17 unit tests covering all transformation stages
- LLM-generated import statements now only work for explicitly
  allowed modules; all others raise ImportError
- Preload modules into safe_globals for direct namespace access
- Updated docstring to document the restriction
- Wrap initial compile in try/except to catch ValueErrors
- Add per-retry logging with attempt counter
- Replace vague failure messages with actionable guidance
  (model suggestions, max_retries hint)
- Add concrete code examples to LLM prompts for better output
- Add module-level _verified_models set for deduplication
- Fix model_exists to handle both dict and object API responses
- Use model attribute (not name) for correct Ollama registry matching
Superseded by examples/README.md and module docstrings.
@nxank4 nxank4 merged commit ef10a26 into main Feb 27, 2026
21 checks passed
@nxank4 nxank4 deleted the refactor/generative-compilation-hardening branch February 27, 2026 18:31
@devactivity-app
Copy link
Copy Markdown

Pull Request Summary by devActivity

Metrics

Cycle Time: 3d 15h 4m Coding Time: 3d 15h 4m

Achievements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant