Skip to content

feat(enforcement): add Smart Enforcement system for improved code quality#15

Merged
victormartingil merged 2 commits intomainfrom
feat/smart-enforcement-v2
Jan 28, 2026
Merged

feat(enforcement): add Smart Enforcement system for improved code quality#15
victormartingil merged 2 commits intomainfrom
feat/smart-enforcement-v2

Conversation

@victormartingil
Copy link
Member

@victormartingil victormartingil commented Jan 28, 2026

Summary

This PR introduces a Smart Enforcement system that transforms Corbat from advisory to enforcing mode.

Problem

The current MCP provides guidelines, but LLMs can ignore them without consequences.

Solution

Five complementary strategies that force LLMs to follow standards:

Strategy Description
Checkpoint Verification JSON checklist required before coding
Real Code Analysis Regex-based anti-pattern detection
Self-Review Mandatory quality self-assessment
Contractual Format Strict response structure enforcement
Verify Tool Gate that must pass before presenting code

Changes

  • New `verify` tool (quality gate)
  • Enhanced `validate` with real analysis
  • New `code-analyzer` module
  • Updated `get_context` output format

Test Plan

  • All existing tests pass
  • New tests for code analyzer (37 test cases)
  • New tests for verify tool (15 test cases)
  • Coverage >= 80% (82.62%)"

…lity

Smart Enforcement upgrades Corbat from advisory mode to enforcing mode by
introducing a mandatory quality gate before code is shown to the user.

New tool:
- verify: quality gate that must PASS before presenting code to the user

Enhanced tools:
- validate: performs real code analysis with 15+ detected anti-patterns
- get_context: includes checkpoint, response format, and self-review

New module:
- src/analysis/code-analyzer.ts: lightweight regex-based code analyzer

Testing:
- add 52 tests (37 for analyzer, 15 for verify)
- maintain coverage at 82.62%

Token impact: ~500–700 additional tokens per interaction
Expected quality improvement: +25–30%

BREAKING CHANGE: validate tool output format changed.
- Refactor assignment-in-while expressions (separate initialization)
- Remove unused `task_type` variable from verify handler
- Fix unnecessary escape in Python regex pattern
- Auto-fix import organization (alphabetical ordering)

All 226 tests pass with 82.62% coverage.
@victormartingil victormartingil merged commit a6cf11a into main Jan 28, 2026
7 checks passed
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