The world's first semantic code debugger with a mathematically proven foundation.
Python Code Harmonizer finds bugs other tools miss by analyzing what your code means, not just what it says.
The core question:
"Does your function DO what its name SAYS it does?"
def get_user(user_id):
"""Retrieve user from database"""
db.delete(user_id) # BUG: Deletes instead of retrieving!
return NoneTraditional tools: β Syntax valid, types correct, no security issues
Harmonizer: π¨ CRITICAL DISHARMONY (1.22) - Function name says "get" but code does "delete"
This is a semantic bug - the kind that causes production incidents because the code lies about what it does.
Every developer has encountered code where:
- Function names lie about what they do
- "Validate" functions secretly modify data
- "Get" functions delete records
- "Check" functions trigger side effects
These intent-execution mismatches cause bugs, confusion, and maintenance nightmares.
Python Code Harmonizer finds them automatically.
The tool is built on proven mathematics:
Four Semantic Dimensions (see MATHEMATICAL_FOUNDATION.md):
- Love (L): Connection, integration, communication
- Justice (J): Correctness, validation, truth
- Power (P): Action, execution, transformation
- Wisdom (W): Information, knowledge, analysis
Proven properties:
- β Orthogonal: Linearly independent (each dimension is unique)
- β Complete: Spans all semantic meaning (everything can be expressed)
- β Minimal: All four necessary (can't remove any)
- β Universal: Applies to all programming languages
Every programming operation maps to these dimensions:
| Your Code | Dimension | Semantic Meaning |
|---|---|---|
get(), read(), query() |
Wisdom | Retrieving information |
validate(), check(), assert |
Justice | Verifying correctness |
create(), update(), delete() |
Power | Changing state |
send(), connect(), notify() |
Love | Integrating systems |
184 programming verbs precisely mapped (see PROGRAMMING_LANGUAGE_SEMANTICS.md)
The tool compares intent (function name) with execution (what it actually does):
# HARMONIOUS (score: 0.05)
def calculate_total(items):
return sum(item.price for item in items)
# Intent: Wisdom (calculate)
# Execution: Wisdom (sum/computation)
# β Aligned!
# DISHARMONIOUS (score: 1.18)
def validate_email(email):
send_welcome_email(email) # Side effect!
return "@" in email
# Intent: Justice (validate)
# Execution: Love (send) + Justice (check)
# β οΈ Validation shouldn't send emails!Distance in 4D semantic space = disharmony score
High distance = intent contradicts execution = probable bug
git clone https://github.com/BruinGrowly/Python-Code-Harmonizer.git
cd Python-Code-Harmonizer
pip install .harmonizer mycode.pyOutput:
======================================================================
Python Code Harmonizer (v2.0)
Powered By: DIVE-V2 (Enhanced Programming Semantics)
Disharmony Threshold: 0.5
======================================================================
Analyzing: mycode.py
----------------------------------------------------------------------
FUNCTION NAME | DISHARMONY SCORE | STATUS
-----------------------------|------------------|--------------------
validate_and_save_user | 0.85 | !! DISHARMONY
get_cached_value | 0.62 | !! DISHARMONY
calculate_total | 0.05 | β HARMONIOUS
delete_expired_records | 0.08 | β HARMONIOUS
======================================================================
| Score | Meaning | Action |
|---|---|---|
| 0.0-0.3 | β Excellent | Code says what it means |
| 0.3-0.5 | Review for clarity | |
| 0.5-0.8 | Notable mismatch - investigate | |
| 0.8-1.2 | β High concern | Significant contradiction |
| 1.2+ | π¨ Critical | Severe disharmony - fix now |
NEW: Complete semantic analysis of entire codebases with git history tracking, architectural debt estimation, and interactive visualizations.
The Legacy Code Mapper answers the challenge: "Legacy code's real complexity still fights back" by providing:
- Semantic Clustering: Maps all files to LJPW space and groups by semantic purpose
- Architectural Smell Detection: Finds God Files, Mixed Concerns, High Disharmony, Semantic Confusion
- Refactoring Opportunities: Ranks files by impact with specific actionable recommendations
- Git History Tracking: Tracks how code evolved semantically over commits
- Architecture Reality Check: Compares documentation vs actual implementation
- Debt Estimation: Calculates technical debt in hours and dollars with priorities
- Interactive Visualizations: 3D semantic maps, drift timelines, HTML exports
# Analyze entire codebase with all features
python -m harmonizer.legacy_mapper <path> --full
# Just the basics (clustering, smells, opportunities)
python -m harmonizer.legacy_mapper <path>
# With specific analyses
python -m harmonizer.legacy_mapper <path> --git-commits 100 --hourly-rate 200
# Export interactive HTML visualization
python -m harmonizer.legacy_mapper <path> --export-htmlπ Analyzing codebase: myproject
Found 45 Python files
β
Analyzed 45 files successfully
======================================================================
SEMANTIC CODEBASE MAP - COMPREHENSIVE ANALYSIS
======================================================================
π WISDOM CLUSTER (28 files)
Avg Coordinates: L=0.15, J=0.20, P=0.01, W=0.48
Files:
- data_processor.py (32 funcs, disharmony: 0.71)
- analyzer.py (18 funcs, disharmony: 0.65)
...
βοΈ JUSTICE CLUSTER (12 files)
Avg Coordinates: L=0.10, J=0.55, P=0.05, W=0.25
Files:
- validators.py (24 funcs, disharmony: 0.58)
...
π OVERALL METRICS
Total files analyzed: 45
Average disharmony: 0.52
Codebase health: MODERATE β οΈ
π¨ ARCHITECTURAL SMELLS (8 detected)
β’ God File: main.py (82 functions)
β’ High Disharmony: legacy_module.py (avg: 0.95)
β’ Mixed Concerns: utils.py (4 semantic dimensions active)
π° ARCHITECTURAL DEBT ESTIMATION
Total Estimated Debt: 127.5 hours ($19,125)
HIGH (6 files) - 89.5hrs ($13,425):
β’ legacy_module.py: $4,500 (High Disharmony + Semantic Confusion)
β’ utils.py: $3,300 (God File + Mixed Concerns)
Git History & Semantic Drift:
# Track how code evolved semantically
python -m harmonizer.legacy_mapper <path> --drift-timelineShows which files changed semantically over time, stability scores, and dimension-specific drift.
Architecture Documentation Check:
# Compare docs vs reality
python -m harmonizer.legacy_mapper <path> --docs-path README.mdValidates whether your documentation matches actual implementation.
Visualizations:
# All visualizations
python -m harmonizer.legacy_mapper <path> --semantic-map --debt-breakdown --export-htmlGenerates:
- 3D semantic space map (ASCII)
- Detailed debt breakdown with cost analysis
- Interactive HTML visualization (open in browser)
- Understanding Legacy Code: Quickly grasp architecture and identify problem areas
- Refactoring Planning: Prioritize what to fix first based on impact and cost
- Code Review: Identify semantic issues before they become bugs
- Technical Debt: Quantify and communicate debt to stakeholders
- Onboarding: Help new developers understand codebase structure
1. Mathematical Proof (MATHEMATICAL_FOUNDATION.md)
- Proves LJPW forms complete semantic basis
- Establishes theoretical foundation for semantic debugging
- Information-theoretic and categorical perspectives
2. Programming Language Theory (PROGRAMMING_LANGUAGE_SEMANTICS.md)
- Comprehensive 1000+ line framework
- Proves all code operations map to LJPW
- Demonstrates all four dimensions necessary for functional code
3. Enhanced Parser (V2) - 7.4x More Powerful
- 184 programming verbs mapped (vs 25 in V1)
- Compound pattern detection (
get_user,send_notification) - Context-aware semantic analysis
- 100% backward compatible
4. Semantic Programming Language (SEMANTIC_PROGRAMMING_LANGUAGE.md)
- Vision for future: languages with semantic types as first-class citizens
- Compile-time semantic verification
- Revolutionary approach to eliminating entire bug classes
| Suite | Tests | Status |
|---|---|---|
| Enhanced Parser | 8 | β 100% |
| Language Semantics | 9 | β 100% |
| Integration | 6 | β 100% |
| Legacy (pytest) | 59 | β 100% |
| Total | 82 | β 100% |
See exactly WHERE code drifts in 4D semantic space:
harmonizer mycode.py --show-trajectoriesdelete_user: !! DISHARMONY (1.41)
π SEMANTIC TRAJECTORY MAP:
ββββββββββββββββββββββββββββββββββββββββββββββββββ
β Dimension Intent Execution Ξ β
ββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Power (P) 1.00 β 0.00 -1.00 β οΈ β
β Wisdom (W) 0.00 β 1.00 +1.00 β οΈ β
ββββββββββββββββββββββββββββββββββββββββββββββββββ
π‘ INTERPRETATION:
Name suggests Power (transformation/control)
but code operates in Wisdom domain (analysis/understanding)
Get intelligent name suggestions based on what code actually does:
harmonizer mycode.py --suggest-namesdelete_user: !! DISHARMONY (1.22)
π‘ SUGGESTED NAMES (based on execution semantics):
Function emphasizes: 50% Love, 50% Wisdom
Suggestions:
β’ notify_user (match: 85%)
β’ inform_user (match: 82%)
β’ communicate_user (match: 80%)
Create .harmonizer.yml in your project:
# Exclude files/directories
exclude:
- "tests/**"
- "venv/**"
- "*.pyc"
# Custom vocabulary for your domain
custom_vocabulary:
authenticate: justice
serialize: wisdom
broadcast: love
execute: power
# Adjust threshold
disharmony_threshold: 0.6See CONFIGURATION.md for full options.
# .github/workflows/harmony-check.yml
- name: Check Code Harmony
run: |
pip install /path/to/Python-Code-Harmonizer
harmonizer src/**/*.py# .pre-commit-config.yaml
- repo: local
hooks:
- id: harmonizer
name: Python Code Harmonizer
entry: harmonizer
language: system
types: [python]Press Ctrl+Shift+P β Tasks: Run Task β Harmonizer: Check Current File
See integration templates for full setup.
Traditional tools check different things:
- Pylint/Flake8: Style and patterns
- MyPy: Type safety
- Pytest: Test correctness
- Bandit: Security vulnerabilities
Python Code Harmonizer checks: Does your code mean what it says?
It's the only tool that:
- β Has a mathematically proven foundation
- β Analyzes semantic meaning, not just syntax
- β Detects when function names lie about implementation
- β Maps code to universal semantic dimensions
- β Finds bugs that pass all other checks
Complementary, not competitive - use it alongside existing tools for comprehensive code quality.
- Quick Reference - One-page cheat sheet
- User Guide - Complete walkthrough
- Tutorial - Hands-on examples
- FAQ - Common questions
- Philosophy - The Anchor Point and Four Dimensions
- Mathematical Foundation - Proof that LJPW forms semantic basis
- LJPW Mathematical Baselines β¨ NEW - Objective baselines with empirical validation
- Baseline Integration Guide π NEW - How baselines enhance harmonizer scoring (v2.0)
- Programming Language Semantics - How code maps to LJPW
- Semantic Programming Language - Future language design
- Architecture - Technical implementation
- Real-World Bugs - 7 semantic bugs other tools miss
- Refactoring Journey - Before/after transformations
- Realistic Samples - Harmonious vs disharmonious code
We welcome contributions! Whether you:
- Found a bug
- Want to add features
- See deeper patterns
- Have questions or ideas
See CONTRIBUTING.md for guidelines.
Development setup:
git clone https://github.com/BruinGrowly/Python-Code-Harmonizer.git
cd Python-Code-Harmonizer
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install -e .
pytest # Run testsThis isn't just a tool - it's applied philosophy with mathematical rigor:
- Orthogonality Proof: L, J, P, W are linearly independent
- Completeness Proof: They span all semantic meaning
- Minimality Proof: All four are necessary
- Empirical Validation: 0.000 error on controlled tests
See MATHEMATICAL_FOUNDATION.md for complete proofs.
The LJPW framework applies beyond Python:
- JavaScript: Same patterns in
async/await, promises, callbacks - Rust: Ownership system maps to Power/Justice dimensions
- Go: Channels and goroutines map to Love (connection)
- Any language: All use these four semantic primitives
Future: Harmonizer for JavaScript, Rust, Go, and more.
The Harmonizer found its own semantic bugs during meta-analysis:
Before:
def visit_Raise(self, node):
"""Process raise statements"""
self._concepts_found.add('raise') # Bug: Unclear semanticsAnalysis: Function name suggests Power (visiting/processing) but used generic "add" (ambiguous).
After Refactoring:
def visit_Raise(self, node):
"""Process raise statements"""
self._record_concept('raise') # Clear: recording for analysisResult: Disharmony score improved from 1.18 β 0.22
See META_ANALYSIS_V2.md for full story.
The Anchor Point (1,1,1,1) represents perfect harmony - the ideal where all four dimensions align perfectly.
Real code approaches this ideal but rarely reaches it. The goal isn't perfection - it's movement toward harmony.
Core insight:
When Intent aligns with Execution, you have harmony. When they contradict, you have disharmony. High disharmony predicts bugs.
This isn't metaphor. It's measurable, testable, mathematical structure.
MIT License - see LICENSE for details.
If you use this tool in research or production:
@software{python_code_harmonizer,
title = {Python Code Harmonizer: Semantic Code Debugging with Mathematical Foundation},
author = {BruinGrowly},
year = {2025},
version = {2.0},
url = {https://github.com/BruinGrowly/Python-Code-Harmonizer},
note = {First semantic debugger with proven LJPW basis}
}- Questions? Check FAQ or Troubleshooting
- Bug reports: GitHub Issues
- Discussions: GitHub Discussions
May your code say what it means, and mean what it says. πβ
Start Here: Quick Reference | User Guide | Tutorial | UX Guide β¨
Theory: Philosophy | Math Foundation | Language Semantics
Examples: Real Bugs | Refactoring | Realistic Samples
Project: Changelog | Contributing | License | UX Design