phi-complexity 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tomy Verreault
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ This software is anchored in the Bibliothèque Céleste — Morphic Phi Framework (φ-Meta).
26
+ The mathematical foundations are derived from the work of Tomy Verreault (2026),
27
+ integrating principles from the Quasicrystal Axioms (AX-A0–AX-A58) and the
28
+ Antifragility Protocol (EQ-AFR-BMAD).
@@ -0,0 +1,195 @@
1
+ Metadata-Version: 2.4
2
+ Name: phi-complexity
3
+ Version: 0.1.0
4
+ Summary: Code quality metrics based on Golden Ratio (φ) mathematical invariants
5
+ Author-email: Tomy Verreault <contact@phidelia.dev>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/spockoo/phi-complexity
8
+ Project-URL: Repository, https://github.com/spockoo/phi-complexity
9
+ Project-URL: Documentation, https://github.com/spockoo/phi-complexity/blob/main/docs/GUIDE.md
10
+ Project-URL: Bug Tracker, https://github.com/spockoo/phi-complexity/issues
11
+ Keywords: code-quality,complexity,golden-ratio,fibonacci,static-analysis,ast,phi,metrics,entropy
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Quality Assurance
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Dynamic: license-file
26
+
27
+ # phi-complexity
28
+
29
+ > *Code quality metrics based on Golden Ratio (φ) mathematical invariants*
30
+
31
+ [![PyPI version](https://img.shields.io/pypi/v/phi-complexity.svg)](https://pypi.org/project/phi-complexity/)
32
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
33
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
34
+ [![Tests](https://img.shields.io/badge/tests-26%20passed-brightgreen)](tests/)
35
+
36
+ `phi-complexity` is the **first code quality library** that measures the health of your Python code using **universal mathematical invariants** derived from the Golden Ratio (φ = 1.618...).
37
+
38
+ Unlike `pylint` (cultural rules) or `radon` (McCabe metrics), `phi-complexity` answers:
39
+
40
+ > *"Is this code in resonance with the natural laws of order, or is it collapsing under its own entropy?"*
41
+
42
+ ---
43
+
44
+ ## ⚡ Quick Start
45
+
46
+ ```bash
47
+ pip install phi-complexity
48
+ ```
49
+
50
+ ```bash
51
+ # Audit a file
52
+ phi check my_script.py
53
+
54
+ # Audit a folder
55
+ phi check ./src/
56
+
57
+ # Generate a Markdown report
58
+ phi report my_script.py --output report.md
59
+
60
+ # CI/CD strict mode (exit 1 if radiance < 75)
61
+ phi check ./src/ --min-radiance 75
62
+ ```
63
+
64
+ ### Python API
65
+
66
+ ```python
67
+ from phi_complexity import auditer, rapport_console, rapport_markdown
68
+
69
+ # Get metrics as a dict
70
+ metrics = auditer("my_script.py")
71
+ print(metrics["radiance"]) # → 82.4
72
+ print(metrics["statut_gnostique"]) # → "EN ÉVEIL ◈"
73
+ print(metrics["oudjat"]) # → {"nom": "process_data", "ligne": 42, ...}
74
+
75
+ # Print console report
76
+ print(rapport_console("my_script.py"))
77
+
78
+ # Save Markdown report
79
+ rapport_markdown("my_script.py", sortie="report.md")
80
+ ```
81
+
82
+ ---
83
+
84
+ ## 📊 Metrics
85
+
86
+ | Metric | Description | Mathematical basis |
87
+ |---|---|---|
88
+ | **Radiance Score** | Global quality score (0–100) | `100 - f(Lilith) - g(H) - h(Anomalies) - i(Fib)` |
89
+ | **Variance de Lilith** | Structural instability | Population variance of function complexities |
90
+ | **Shannon Entropy** | Information density | `H = -Σ p·log₂(p)` |
91
+ | **φ-Ratio** | Dominant function ratio | `max_complexity / mean` → should tend toward φ |
92
+ | **Fibonacci Distance** | Natural size alignment | `Σ|n_i - Fib_k| / φ` |
93
+ | **Zeta-Score** | Global resonance | `ζ_meta(functions, φ)` converging series |
94
+
95
+ ### Gnostic Status Levels
96
+
97
+ | Score | Status | Meaning |
98
+ |---|---|---|
99
+ | ≥ 85 | **HERMÉTIQUE ✦** | Stable, harmonious, production-ready |
100
+ | 60–84 | **EN ÉVEIL ◈** | Potential exists, some entropy zones |
101
+ | < 60 | **DORMANT ░** | Deep restructuring recommended |
102
+
103
+ ---
104
+
105
+ ## 🔍 Sample Output
106
+
107
+ ```
108
+ ╔══════════════════════════════════════════════════╗
109
+ ║ PHI-COMPLEXITY — AUDIT DE RADIANCE ║
110
+ ╚══════════════════════════════════════════════════╝
111
+
112
+ 📄 Fichier : my_script.py
113
+ 📅 Date : 2026-04-08 17:11
114
+
115
+ ☼ RADIANCE : ██████████████░░░░░░ 72.6 / 100
116
+ ⚖ LILITH : 11221.9 (Structural variance)
117
+ 🌊 ENTROPIE : 2.48 bits (Shannon)
118
+ ◈ PHI-RATIO : 3.43 (ideal: φ = 1.618, Δ=1.81)
119
+ ζ ZETA-SCORE : 0.3656 (Global resonance)
120
+
121
+ STATUT : EN ÉVEIL ◈
122
+
123
+ 🔎 OUDJAT : 'process_data' (Line 42, Complexity: 376)
124
+
125
+ ⚠ SUTURES IDENTIFIED (2):
126
+ 🟡 Line 18 [LILITH] : Nested loop (depth 2). Consider a helper function.
127
+ >> for j in range(b):
128
+ 🔵 Line 67 [SOUVERAINETE] : 'load_data' receives 6 arguments. Encapsulate in an object.
129
+ >> def load_data(path, sep, enc, cols, dtype, na):
130
+ ```
131
+
132
+ ---
133
+
134
+ ## 🧮 Mathematical Foundations
135
+
136
+ The **Radiance Formula** is derived from:
137
+
138
+ - **φ-Meta Framework** (Tomy Verreault, 2026) — Axioms AX-A0 through AX-A58
139
+ - **Law of Antifragility** (EQ-AFR-BMAD): `φ_{t+1} = P_φ(φ_t + k·Var(E_t)·E_t)`
140
+ - **Cybernetics** (Korchounov, Mir, 1975) — Feedback and variance as control metrics
141
+ - **Shannon Information Theory** — Code as an information channel
142
+
143
+ The **Sovereign Coding Rules** are derived from:
144
+ - **The C Book** (Banahan, Brady, Doran) — Scope hermeticity, resource lifecycle
145
+ - **JaCaMo / Multi-Agent Programming** — Agent independence and encapsulation
146
+
147
+ Full mathematical proof: [docs/MATHEMATIQUES.md](docs/MATHEMATIQUES.md)
148
+
149
+ ---
150
+
151
+ ## 🏗 Sovereign Architecture
152
+
153
+ ```
154
+ Zero external dependencies.
155
+ Pure Python standard library (ast, math, json).
156
+ ```
157
+
158
+ ```
159
+ phi_complexity/
160
+ ├── core.py ← Golden constants (PHI, TAXE_SUTURE, ETA_GOLDEN...)
161
+ ├── analyseur.py ← AST fractal dissection
162
+ ├── metriques.py ← Radiance Index calculation
163
+ ├── rapport.py ← Console / Markdown / JSON rendering
164
+ └── cli.py ← phi check / phi report
165
+ ```
166
+
167
+ ---
168
+
169
+ ## 🔗 Integration
170
+
171
+ ### Pre-commit Hook
172
+ ```yaml
173
+ repos:
174
+ - repo: https://github.com/spockoo/phi-complexity
175
+ rev: v0.1.0
176
+ hooks:
177
+ - id: phi-check
178
+ args: [--min-radiance, "70"]
179
+ ```
180
+
181
+ ### GitHub Action
182
+ ```yaml
183
+ - name: Phi-Complexity Audit
184
+ run: |
185
+ pip install phi-complexity
186
+ phi check ./src/ --min-radiance 75
187
+ ```
188
+
189
+ ---
190
+
191
+ ## 📜 License
192
+
193
+ MIT — Tomy Verreault, 2026
194
+
195
+ *Anchored in the Bibliothèque Céleste — Morphic Phi Framework (φ-Meta)*
@@ -0,0 +1,169 @@
1
+ # phi-complexity
2
+
3
+ > *Code quality metrics based on Golden Ratio (φ) mathematical invariants*
4
+
5
+ [![PyPI version](https://img.shields.io/pypi/v/phi-complexity.svg)](https://pypi.org/project/phi-complexity/)
6
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
8
+ [![Tests](https://img.shields.io/badge/tests-26%20passed-brightgreen)](tests/)
9
+
10
+ `phi-complexity` is the **first code quality library** that measures the health of your Python code using **universal mathematical invariants** derived from the Golden Ratio (φ = 1.618...).
11
+
12
+ Unlike `pylint` (cultural rules) or `radon` (McCabe metrics), `phi-complexity` answers:
13
+
14
+ > *"Is this code in resonance with the natural laws of order, or is it collapsing under its own entropy?"*
15
+
16
+ ---
17
+
18
+ ## ⚡ Quick Start
19
+
20
+ ```bash
21
+ pip install phi-complexity
22
+ ```
23
+
24
+ ```bash
25
+ # Audit a file
26
+ phi check my_script.py
27
+
28
+ # Audit a folder
29
+ phi check ./src/
30
+
31
+ # Generate a Markdown report
32
+ phi report my_script.py --output report.md
33
+
34
+ # CI/CD strict mode (exit 1 if radiance < 75)
35
+ phi check ./src/ --min-radiance 75
36
+ ```
37
+
38
+ ### Python API
39
+
40
+ ```python
41
+ from phi_complexity import auditer, rapport_console, rapport_markdown
42
+
43
+ # Get metrics as a dict
44
+ metrics = auditer("my_script.py")
45
+ print(metrics["radiance"]) # → 82.4
46
+ print(metrics["statut_gnostique"]) # → "EN ÉVEIL ◈"
47
+ print(metrics["oudjat"]) # → {"nom": "process_data", "ligne": 42, ...}
48
+
49
+ # Print console report
50
+ print(rapport_console("my_script.py"))
51
+
52
+ # Save Markdown report
53
+ rapport_markdown("my_script.py", sortie="report.md")
54
+ ```
55
+
56
+ ---
57
+
58
+ ## 📊 Metrics
59
+
60
+ | Metric | Description | Mathematical basis |
61
+ |---|---|---|
62
+ | **Radiance Score** | Global quality score (0–100) | `100 - f(Lilith) - g(H) - h(Anomalies) - i(Fib)` |
63
+ | **Variance de Lilith** | Structural instability | Population variance of function complexities |
64
+ | **Shannon Entropy** | Information density | `H = -Σ p·log₂(p)` |
65
+ | **φ-Ratio** | Dominant function ratio | `max_complexity / mean` → should tend toward φ |
66
+ | **Fibonacci Distance** | Natural size alignment | `Σ|n_i - Fib_k| / φ` |
67
+ | **Zeta-Score** | Global resonance | `ζ_meta(functions, φ)` converging series |
68
+
69
+ ### Gnostic Status Levels
70
+
71
+ | Score | Status | Meaning |
72
+ |---|---|---|
73
+ | ≥ 85 | **HERMÉTIQUE ✦** | Stable, harmonious, production-ready |
74
+ | 60–84 | **EN ÉVEIL ◈** | Potential exists, some entropy zones |
75
+ | < 60 | **DORMANT ░** | Deep restructuring recommended |
76
+
77
+ ---
78
+
79
+ ## 🔍 Sample Output
80
+
81
+ ```
82
+ ╔══════════════════════════════════════════════════╗
83
+ ║ PHI-COMPLEXITY — AUDIT DE RADIANCE ║
84
+ ╚══════════════════════════════════════════════════╝
85
+
86
+ 📄 Fichier : my_script.py
87
+ 📅 Date : 2026-04-08 17:11
88
+
89
+ ☼ RADIANCE : ██████████████░░░░░░ 72.6 / 100
90
+ ⚖ LILITH : 11221.9 (Structural variance)
91
+ 🌊 ENTROPIE : 2.48 bits (Shannon)
92
+ ◈ PHI-RATIO : 3.43 (ideal: φ = 1.618, Δ=1.81)
93
+ ζ ZETA-SCORE : 0.3656 (Global resonance)
94
+
95
+ STATUT : EN ÉVEIL ◈
96
+
97
+ 🔎 OUDJAT : 'process_data' (Line 42, Complexity: 376)
98
+
99
+ ⚠ SUTURES IDENTIFIED (2):
100
+ 🟡 Line 18 [LILITH] : Nested loop (depth 2). Consider a helper function.
101
+ >> for j in range(b):
102
+ 🔵 Line 67 [SOUVERAINETE] : 'load_data' receives 6 arguments. Encapsulate in an object.
103
+ >> def load_data(path, sep, enc, cols, dtype, na):
104
+ ```
105
+
106
+ ---
107
+
108
+ ## 🧮 Mathematical Foundations
109
+
110
+ The **Radiance Formula** is derived from:
111
+
112
+ - **φ-Meta Framework** (Tomy Verreault, 2026) — Axioms AX-A0 through AX-A58
113
+ - **Law of Antifragility** (EQ-AFR-BMAD): `φ_{t+1} = P_φ(φ_t + k·Var(E_t)·E_t)`
114
+ - **Cybernetics** (Korchounov, Mir, 1975) — Feedback and variance as control metrics
115
+ - **Shannon Information Theory** — Code as an information channel
116
+
117
+ The **Sovereign Coding Rules** are derived from:
118
+ - **The C Book** (Banahan, Brady, Doran) — Scope hermeticity, resource lifecycle
119
+ - **JaCaMo / Multi-Agent Programming** — Agent independence and encapsulation
120
+
121
+ Full mathematical proof: [docs/MATHEMATIQUES.md](docs/MATHEMATIQUES.md)
122
+
123
+ ---
124
+
125
+ ## 🏗 Sovereign Architecture
126
+
127
+ ```
128
+ Zero external dependencies.
129
+ Pure Python standard library (ast, math, json).
130
+ ```
131
+
132
+ ```
133
+ phi_complexity/
134
+ ├── core.py ← Golden constants (PHI, TAXE_SUTURE, ETA_GOLDEN...)
135
+ ├── analyseur.py ← AST fractal dissection
136
+ ├── metriques.py ← Radiance Index calculation
137
+ ├── rapport.py ← Console / Markdown / JSON rendering
138
+ └── cli.py ← phi check / phi report
139
+ ```
140
+
141
+ ---
142
+
143
+ ## 🔗 Integration
144
+
145
+ ### Pre-commit Hook
146
+ ```yaml
147
+ repos:
148
+ - repo: https://github.com/spockoo/phi-complexity
149
+ rev: v0.1.0
150
+ hooks:
151
+ - id: phi-check
152
+ args: [--min-radiance, "70"]
153
+ ```
154
+
155
+ ### GitHub Action
156
+ ```yaml
157
+ - name: Phi-Complexity Audit
158
+ run: |
159
+ pip install phi-complexity
160
+ phi check ./src/ --min-radiance 75
161
+ ```
162
+
163
+ ---
164
+
165
+ ## 📜 License
166
+
167
+ MIT — Tomy Verreault, 2026
168
+
169
+ *Anchored in the Bibliothèque Céleste — Morphic Phi Framework (φ-Meta)*
@@ -0,0 +1,65 @@
1
+ """
2
+ __init__.py — API publique de phi-complexity.
3
+ Expose les fonctions de haut niveau pour une utilisation simple.
4
+ """
5
+ from .core import PHI, TAXE_SUTURE, ETA_GOLDEN, VERSION, AUTEUR, FRAMEWORK
6
+ from .analyseur import AnalyseurPhi
7
+ from .metriques import CalculateurRadiance
8
+ from .rapport import GenerateurRapport
9
+
10
+
11
+ def auditer(fichier: str) -> dict:
12
+ """
13
+ Lance un audit complet sur un fichier Python.
14
+ Retourne un dictionnaire de métriques.
15
+
16
+ Usage:
17
+ from phi_complexity import auditer
18
+ result = auditer("mon_script.py")
19
+ print(result["radiance"]) # → 82.4
20
+ """
21
+ analyseur = AnalyseurPhi(fichier)
22
+ resultat = analyseur.analyser()
23
+ calculateur = CalculateurRadiance(resultat)
24
+ return calculateur.calculer()
25
+
26
+
27
+ def rapport_console(fichier: str) -> str:
28
+ """Retourne le rapport ASCII formaté pour le terminal."""
29
+ metriques = auditer(fichier)
30
+ return GenerateurRapport(metriques).console()
31
+
32
+
33
+ def rapport_markdown(fichier: str, sortie: str = None) -> str:
34
+ """
35
+ Génère un rapport Markdown.
36
+ Si `sortie` est spécifié, sauvegarde dans ce fichier.
37
+ Retourne le contenu Markdown.
38
+ """
39
+ metriques = auditer(fichier)
40
+ gen = GenerateurRapport(metriques)
41
+ if sortie:
42
+ gen.sauvegarder_markdown(sortie)
43
+ return gen.markdown()
44
+
45
+
46
+ def rapport_json(fichier: str) -> str:
47
+ """Retourne le rapport JSON pour CI/CD."""
48
+ metriques = auditer(fichier)
49
+ return GenerateurRapport(metriques).json()
50
+
51
+
52
+ __version__ = VERSION
53
+ __author__ = AUTEUR
54
+ __all__ = [
55
+ "auditer",
56
+ "rapport_console",
57
+ "rapport_markdown",
58
+ "rapport_json",
59
+ "PHI",
60
+ "TAXE_SUTURE",
61
+ "ETA_GOLDEN",
62
+ "AnalyseurPhi",
63
+ "CalculateurRadiance",
64
+ "GenerateurRapport",
65
+ ]
@@ -0,0 +1,3 @@
1
+ """Point d'entrée pour python -m phi_complexity"""
2
+ from phi_complexity.cli import main
3
+ main()