Target Version: CodeSlim v2.0 (The Deterministic AI Output Governance Gateway)
Core Identity: Sitting as a model-agnostic, deterministic security and quality gateway between autonomous AI agents / developers and git repositories.
CodeSlim 2.0 evolves from a single-file CLI/Web Studio minimizer into a Deterministic AI Output Governance Gateway & System-Level Code Intelligence Engine.
- Zero Hallucinated Dependency Incidents: Active PyPI JSON API & DepScope verification blocking un-verified packages before CI build execution.
- Dynamic Confidence Degradation: Automatic fallbacks based on test coverage (Coverage < 30% degrades strictly to Node 2.5 Deterministic LibCST Mode).
- Tier 2 Differential Test Execution Gate: Automated
pytestexecution running baseline vs post-refactor suites to guarantee 0 behavioral regressions. - System-Level Architectural Graph Intelligence: Evolving cross-file analysis to detect circular dependency sprawl, layer boundary violations, and cross-module phantom symbols.
- 40% AI Token Cost Reduction Telemetry: Built-in dollar-denominated token spend reduction tracker.
┌─────────────────────────────────────────────────────────────────────────────┐
│ CODESLIM v2.0 MILESTONE ROADMAP │
├─────────────────────────────────────────────────────────────────────────────┤
│ MILESTONE 1: TELEMETRY ENGINE & CORE 4 HARDENING │
│ • Telemetry Tracker (Token $ saved, AST rejections, Hallucination blocks) │
│ • Async PyPI Batch Lookup & Registry Cache │
├─────────────────────────────────────────────────────────────────────────────┤
│ MILESTONE 2: DYNAMIC CONFIDENCE DEGRADATION & TEST GATE │
│ • Coverage-based Degradation Engine │
│ • Differential pytest Execution Runner & Auto-Rollback Gate │
├─────────────────────────────────────────────────────────────────────────────┤
│ MILESTONE 3: SYSTEM-LEVEL DEPENDENCY GRAPH ENGINE │
│ • Cross-Module Layer Violation & Circular Import Detector │
│ • Project-Wide Phantom Symbol Graph │
├─────────────────────────────────────────────────────────────────────────────┤
│ MILESTONE 4: ENTERPRISE CI GOVERNANCE & GITHUB BOT │
│ • Node 2.5 Auto-Apply vs Node 3 PR-Only Policy Enforcer │
│ • Zero-Permission Web Studio Playground & HTML Observatory Export │
└─────────────────────────────────────────────────────────────────────────────┘
- Goal: Track empirical financial and security value delivered per file scan and PR execution.
- New File:
codeslim/telemetry/tracker.py - Features:
tokens_saved_count: Exact integer of prompt tokens pruned.dollars_saved_usd: Calculated based on target model pricing (GPT-4o, Claude 3.5 Sonnet).hallucinated_packages_blocked: Count of non-existent PyPI package calls intercepted.ast_gate_rejections: Count of invalid AST mutations caught.
- Goal: Guarantee zero behavioral regressions when test suites are weak, absent, or present.
- New File:
codeslim/optimizer/test_gate.py - New File:
codeslim/pipeline/confidence_degradation.py - Workflow:
Test Coverage Assessment ──► Coverage < 30% ──► Node 2.5 Deterministic Mode (0% LLM Risk) ──► Coverage 30-80%──► PR Suggestion-Only Mode (Human Review) ──► Coverage > 80% ──► Differential Pytest Gate (Auto-Write if Pass)
-
Goal: Move from file-level micro metrics (
$CC$ , nesting) to repository-wide dependency integrity. -
New File:
codeslim/analyzers/system_graph.py -
Features:
- Multi-module symbol dependency matrix.
- Circular import detection (
import A -> B -> A). - Architectural layer boundary enforcement (e.g.
domainmodules cannot importuiorinfrastructure).
- Goal: Enforce strict CI write policies on incoming AI agent Pull Requests.
- File to Update: pr_handler.py
-
Policy Matrix:
-
Node 2.5 (LibCST Deterministic Fixes)$\rightarrow$ Auto-Apply Allowed (Loss-less syntax changes). -
Node 3 (LLM Generative Refactoring)$\rightarrow$ PR-Only / Suggestion Diff (Requires human review click).
-
tests/telemetry/test_tracker.py: Test dollar cost calculation and token metrics aggregation.tests/optimizer/test_differential_gate.py: Testpytestsub-process execution and automatic rollback on test failure.tests/analyzers/test_system_graph.py: Test circular import detection and cross-module phantom symbol extraction.tests/pipeline/test_confidence_degradation.py: Test automatic fallback to Node 2.5 when coverage < 30%.
- Execute
codeslim scan ./codeslim --export-html docs/index.htmland verify live telemetry metrics display in the Observatory dashboard. - Run a 100-file project scan in
--no-llmmode to benchmark < 2s execution velocity.
- All 4 components implemented with 100% strict type hints and Google-style docstrings.
- 0 errors on
python -m ruff check codeslim/ tests/. - 0 errors on
python -m mypy codeslim/. - 100% green passing result on full test suite (
python -m pytest -v). - Updated documentation in CODESLIM_GUIDE.md.