1- # Python Code Harmonizer (LJPW v4.0 )
1+ # Python Code Harmonizer (LJPW v5.1 )
22
33** The Physics of Software Quality.**
44
5- The Python Code Harmonizer is a next-generation static analysis and visualization tool that evaluates codebases using the ** LJPW v4.0 Framework** (Love, Justice, Power, Wisdom). It treats code as a dynamic system, using non-linear physics models to predict technical debt, identify architectural smells, and guide refactoring.
5+ The Python Code Harmonizer is a next-generation static analysis and visualization tool that evaluates codebases across four fundamental dimensions. It treats code as a dynamic system, using non-linear physics models to predict technical debt, identify architectural smells, and guide refactoring.
6+
7+ ## The Four Dimensions
8+
9+ | Dimension | What It Measures | Low Score Means | High Score Means |
10+ | -----------| ------------------| -----------------| ------------------|
11+ | ** Cohesion** | Integration, connectivity, module relationships | Isolated, fragmented code | Well-connected, communicating modules |
12+ | ** Structure** | Validation, type safety, contracts, consistency | Loose, unvalidated code | Strong contracts, type-safe, tested |
13+ | ** Complexity** | Execution density, logic, cyclomatic complexity | Simple, straightforward code | Dense logic, many branches |
14+ | ** Abstraction** | Documentation, patterns, architecture, design | Raw implementation | Well-documented, patterned code |
615
716![ LJPW Dashboard] ( examples/ljpw_v4_demo_plot.png )
817
@@ -32,27 +41,47 @@ The Python Code Harmonizer is a next-generation static analysis and visualizatio
3241
3342## Key Features
3443
35- ### 1. 🌌 Dynamic Physics Model (LJPW v4.0 )
44+ ### 1. 🌌 Dynamic Physics Model (LJPW v5.1 )
3645Unlike traditional linters that count errors, the Harmonizer simulates your code's "energy state" over time.
37- - ** Natural Equilibrium (NE)** : Stable state for healthy code ( ` L=0.62, J=0.41, P=0.72, W=0.69 ` ) .
46+ - ** Natural Equilibrium (NE)** : Stable state for healthy code.
3847- ** High-Energy State** : "Thriving" state for complex, well-architected systems.
39- - ** Entropy Detection** : Predicts "Justice Collapse" (technical debt avalanches) before they happen.
48+ - ** Complexity Erosion Detection** : Predicts when high complexity without abstraction will degrade structure.
49+
50+ ### 2. 🔄 Resonance Engine (NEW)
51+ Advanced dynamic analysis that reveals what your codebase is missing.
52+
53+ ``` python
54+ from harmonizer.resonance_engine import ResonanceEngine, detect_power_erosion
4055
41- ### 2. 📊 Visual Analytics
56+ engine = ResonanceEngine()
57+
58+ # Full analysis of code coordinates
59+ result = engine.full_analysis((0.5 , 0.4 , 0.8 , 0.3 ), cycles = 100 )
60+ print (f " Primary deficit: { result[' summary' ][' primary_deficit' ]} " )
61+ print (f " Erosion risk: { result[' summary' ][' power_erosion_risk' ]} " )
62+ ```
63+
64+ ** Key Metrics:**
65+ - ** Voltage** : Semantic energy of code (` √(L² + J² + P² + W²) ` ) - measures "aliveness"
66+ - ** Complexity Erosion** : Detects when high complexity erodes structure without abstraction protection
67+ - ** Earned Depth** : Tracks refactoring journey - hard paths earn more depth than easy ones
68+ - ** Deficit Analysis** : Identifies which dimension your codebase is starving for
69+
70+ ### 3. 📊 Visual Analytics
4271Generate interactive HTML reports to explore your codebase's semantic structure.
43- - ** Radar Charts** : Visualize the balance of Love (Care), Justice ( Structure), Power (Action) , and Wisdom ( Abstraction) .
72+ - ** Radar Charts** : Visualize the balance of Cohesion, Structure, Complexity , and Abstraction.
4473- ** Dependency Galaxy** : A force-directed graph showing the "gravitational pull" of your modules.
45- - ** Semantic Density** : Identify "Anemic Components" (high complexity, low action ).
74+ - ** Semantic Density** : Identify "Anemic Components" (high complexity, low abstraction ).
4675
47- ### 3 . 🛡️ CI/CD Integration
76+ ### 4 . 🛡️ CI/CD Integration
4877Prevent entropy decay with built-in quality gates.
4978- ** ` check_harmony.py ` ** : CLI tool for CI pipelines. Fails builds if code drifts too far from equilibrium.
5079- ** GitHub Action** : Ready-to-use workflow in ` .github/workflows/ljpw_gate.yml ` .
5180- ** Pre-commit Hook** : Local checks via ` .pre-commit-config.yaml ` .
5281
53- ### 4 . 🔬 Relationship Analysis
54- Validate that your system exhibits healthy LJPW coupling patterns.
55- - ** Pattern Validation** : Check if Love amplifies, Power is constrained
82+ ### 5 . 🔬 Relationship Analysis
83+ Validate that your system exhibits healthy coupling patterns.
84+ - ** Pattern Validation** : Check if Cohesion amplifies, Complexity is constrained
5685- ** Proportion Analysis** : Verify scale-invariant ratios
5786- ** Structural Health** : Diagnose relationship issues vs. magnitude issues
5887
@@ -64,7 +93,7 @@ print(f"Health: {result['overall_health']:.0%}")
6493# Provides actionable recommendations
6594```
6695
67- ### 5 . ⚙️ Developer Experience
96+ ### 6 . ⚙️ Developer Experience
6897- ** Configurable** : Customize thresholds in ` pyproject.toml ` or ` harmonizer.yaml ` .
6998- ** Ignore System** : Exclude files using ` .harmonizerignore ` .
7099
@@ -120,30 +149,34 @@ exclude = ["venv", "tests"]
120149
121150## The LJPW Framework
122151
123- ### The Four Dimensions
152+ The framework uses internal variable names L, J, P, W (derived from philosophical concepts) which map to practical software metrics:
153+
154+ ### Dimension Mapping
124155
125- - ** Love (L)** : Care, readability, comments, user-focus.
126- - ** Justice (J)** : Structure, types, tests, consistency.
127- - ** Power (P)** : Action, logic, complexity, performance.
128- - ** Wisdom (W)** : Abstraction, architecture, patterns, insight.
156+ | Internal | Developer Term | What It Measures |
157+ | ----------| ---------------| ------------------|
158+ | ** L** | Cohesion | Integration, connectivity, module relationships |
159+ | ** J** | Structure | Validation, type safety, contracts, consistency |
160+ | ** P** | Complexity | Execution density, logic, cyclomatic complexity |
161+ | ** W** | Abstraction | Documentation, patterns, architecture, design |
129162
130163### Scale Invariance & Relationship Structure
131164
132165** Key Insight** : * The relationships between dimensions are more important than their absolute values.*
133166
134- The LJPW Framework exhibits ** scale invariance** - the same proportional relationships (L:J:P: W ≈ 1.5:1:1.7:1.7) define healthy systems at any scale:
167+ The framework exhibits ** scale invariance** - the same proportional relationships (L:J:P: W ≈ 1.5:1:1.7:1.7) define healthy systems at any scale:
135168
136- - ** Small team ** : (6, 4, 7, 7) developers
169+ - ** Small module ** : (6, 4, 7, 7) metrics
137170- ** Medium project** : (62, 41, 72, 69) metrics
138- - ** Large organization ** : (618, 414, 718, 693) person-hours
171+ - ** Large codebase ** : (618, 414, 718, 693) metrics
139172
140173** Coupling Structure** encodes how dimensions interact:
141- - ** Love amplifies** other dimensions (multiplier effect)
142- - ** Power must be constrained** (channeled through Love/Wisdom )
143- - ** Justice supports Wisdom ** (truth-seeking flows to understanding)
144- - ** Asymmetry is fundamental** (giving ≠ receiving )
174+ - ** Cohesion amplifies** other dimensions (multiplier effect)
175+ - ** Complexity must be constrained** (channeled through Cohesion/Abstraction )
176+ - ** Structure supports Abstraction ** (validation flows to understanding)
177+ - ** Asymmetry is fundamental** (dependencies are directional )
145178
146- This structural universality makes the framework applicable across domains: code quality, team dynamics, organizational health , and ecosystems .
179+ This structural universality makes the framework applicable across scales: functions, modules, packages , and entire codebases .
147180
148181** Learn more** : See [ Relationship Insight Analysis] ( RELATIONSHIP_INSIGHT_SYNTHESIS.md )
149182
0 commit comments