phi-complexity 0.1.2__tar.gz → 0.1.9__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.
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/PKG-INFO +195 -195
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/phi_complexity/__init__.py +32 -11
- phi_complexity-0.1.9/phi_complexity/akasha.py +158 -0
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/phi_complexity/analyseur.py +97 -35
- phi_complexity-0.1.9/phi_complexity/autosuture.py +76 -0
- phi_complexity-0.1.9/phi_complexity/backends/__init__.py +6 -0
- phi_complexity-0.1.9/phi_complexity/backends/base.py +20 -0
- phi_complexity-0.1.9/phi_complexity/backends/c_rust_light.py +87 -0
- phi_complexity-0.1.9/phi_complexity/backends/python.py +18 -0
- phi_complexity-0.1.9/phi_complexity/backup.py +61 -0
- phi_complexity-0.1.9/phi_complexity/bmad.py +73 -0
- phi_complexity-0.1.9/phi_complexity/cli.py +356 -0
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/phi_complexity/core.py +39 -14
- phi_complexity-0.1.9/phi_complexity/gnose.py +83 -0
- phi_complexity-0.1.9/phi_complexity/impossible.py +84 -0
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/phi_complexity/metriques.py +40 -28
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/phi_complexity/rapport.py +5 -7
- phi_complexity-0.1.9/phi_complexity/suture.py +116 -0
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/phi_complexity.egg-info/PKG-INFO +195 -195
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/phi_complexity.egg-info/SOURCES.txt +11 -0
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/pyproject.toml +16 -1
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/setup.cfg +4 -4
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/tests/test_analyseur.py +0 -2
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/tests/test_core.py +0 -1
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/tests/test_rapport.py +1 -1
- phi_complexity-0.1.2/phi_complexity/cli.py +0 -183
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/LICENSE +0 -0
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/README.md +0 -0
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/phi_complexity/__main__.py +0 -0
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/phi_complexity.egg-info/dependency_links.txt +0 -0
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/phi_complexity.egg-info/entry_points.txt +0 -0
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/phi_complexity.egg-info/top_level.txt +0 -0
- {phi_complexity-0.1.2 → phi_complexity-0.1.9}/tests/test_cli.py +0 -0
|
@@ -1,195 +1,195 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: phi-complexity
|
|
3
|
-
Version: 0.1.
|
|
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
|
-
[](https://pypi.org/project/phi-complexity/)
|
|
32
|
-
[](https://www.python.org/downloads/)
|
|
33
|
-
[](https://github.com/spockoo/phi-complexity/blob/main/LICENSE)
|
|
34
|
-
[](https://github.com/spockoo/phi-complexity/tree/main/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](https://github.com/spockoo/phi-complexity/blob/main/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)*
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: phi-complexity
|
|
3
|
+
Version: 0.1.9
|
|
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
|
+
[](https://pypi.org/project/phi-complexity/)
|
|
32
|
+
[](https://www.python.org/downloads/)
|
|
33
|
+
[](https://github.com/spockoo/phi-complexity/blob/main/LICENSE)
|
|
34
|
+
[](https://github.com/spockoo/phi-complexity/tree/main/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](https://github.com/spockoo/phi-complexity/blob/main/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)*
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
from .core import PHI, TAXE_SUTURE, ETA_GOLDEN, VERSION, AUTEUR, FRAMEWORK
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from typing import Dict, Any, Optional
|
|
3
|
+
from .core import PHI, TAXE_SUTURE, ETA_GOLDEN, VERSION, AUTEUR
|
|
6
4
|
from .analyseur import AnalyseurPhi
|
|
7
5
|
from .metriques import CalculateurRadiance
|
|
8
6
|
from .rapport import GenerateurRapport
|
|
7
|
+
from .suture import SutureAgent
|
|
9
8
|
|
|
10
9
|
|
|
11
|
-
def auditer(fichier: str) ->
|
|
10
|
+
def auditer(fichier: str) -> Dict[str, Any]:
|
|
12
11
|
"""
|
|
13
12
|
Lance un audit complet sur un fichier Python.
|
|
14
13
|
Retourne un dictionnaire de métriques.
|
|
@@ -18,9 +17,9 @@ def auditer(fichier: str) -> dict:
|
|
|
18
17
|
result = auditer("mon_script.py")
|
|
19
18
|
print(result["radiance"]) # → 82.4
|
|
20
19
|
"""
|
|
21
|
-
analyseur = AnalyseurPhi(fichier)
|
|
20
|
+
analyseur: AnalyseurPhi = AnalyseurPhi(fichier)
|
|
22
21
|
resultat = analyseur.analyser()
|
|
23
|
-
calculateur = CalculateurRadiance(resultat)
|
|
22
|
+
calculateur: CalculateurRadiance = CalculateurRadiance(resultat)
|
|
24
23
|
return calculateur.calculer()
|
|
25
24
|
|
|
26
25
|
|
|
@@ -30,14 +29,14 @@ def rapport_console(fichier: str) -> str:
|
|
|
30
29
|
return GenerateurRapport(metriques).console()
|
|
31
30
|
|
|
32
31
|
|
|
33
|
-
def rapport_markdown(fichier: str, sortie: str = None) -> str:
|
|
32
|
+
def rapport_markdown(fichier: str, sortie: Optional[str] = None) -> str:
|
|
34
33
|
"""
|
|
35
34
|
Génère un rapport Markdown.
|
|
36
35
|
Si `sortie` est spécifié, sauvegarde dans ce fichier.
|
|
37
36
|
Retourne le contenu Markdown.
|
|
38
37
|
"""
|
|
39
|
-
metriques = auditer(fichier)
|
|
40
|
-
gen = GenerateurRapport(metriques)
|
|
38
|
+
metriques: Dict[str, Any] = auditer(fichier)
|
|
39
|
+
gen: GenerateurRapport = GenerateurRapport(metriques)
|
|
41
40
|
if sortie:
|
|
42
41
|
gen.sauvegarder_markdown(sortie)
|
|
43
42
|
return gen.markdown()
|
|
@@ -49,6 +48,26 @@ def rapport_json(fichier: str) -> str:
|
|
|
49
48
|
return GenerateurRapport(metriques).json()
|
|
50
49
|
|
|
51
50
|
|
|
51
|
+
def suture(fichier: str, api_url: Optional[str] = None) -> str:
|
|
52
|
+
"""
|
|
53
|
+
Invoque Phidélia pour proposer une suture du fichier.
|
|
54
|
+
Retourne la suggestion de l'IA (Markdown).
|
|
55
|
+
"""
|
|
56
|
+
from .analyseur import AnalyseurPhi
|
|
57
|
+
from .metriques import CalculateurRadiance
|
|
58
|
+
|
|
59
|
+
analyseur = AnalyseurPhi(fichier)
|
|
60
|
+
resultat = analyseur.analyser()
|
|
61
|
+
|
|
62
|
+
# On injecte les métriques de radiance dans le résultat pour Phidélia
|
|
63
|
+
calculateur = CalculateurRadiance(resultat)
|
|
64
|
+
metriques = calculateur.calculer()
|
|
65
|
+
resultat.radiance = metriques["radiance"]
|
|
66
|
+
|
|
67
|
+
agent = SutureAgent(api_url) if api_url else SutureAgent()
|
|
68
|
+
return agent.suturer(resultat)
|
|
69
|
+
|
|
70
|
+
|
|
52
71
|
__version__ = VERSION
|
|
53
72
|
__author__ = AUTEUR
|
|
54
73
|
__all__ = [
|
|
@@ -62,4 +81,6 @@ __all__ = [
|
|
|
62
81
|
"AnalyseurPhi",
|
|
63
82
|
"CalculateurRadiance",
|
|
64
83
|
"GenerateurRapport",
|
|
84
|
+
"SutureAgent",
|
|
85
|
+
"suture",
|
|
65
86
|
]
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import os
|
|
3
|
+
import json
|
|
4
|
+
import time
|
|
5
|
+
import math
|
|
6
|
+
from typing import Dict, Any, List, Optional
|
|
7
|
+
from .core import PHI
|
|
8
|
+
|
|
9
|
+
# ────────────────────────────────────────────────────────
|
|
10
|
+
# MOTEUR DE MATRICE HOLOGRAPHIQUE BINAIRE (Phidélia v11.6)
|
|
11
|
+
# ────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
class MatriceHolographique:
|
|
14
|
+
"""
|
|
15
|
+
Transforme un dictionnaire de métriques en résonances harmoniques
|
|
16
|
+
dans l'anneau Z[φ]. (Inspiré de EQ-BIN-010 et EQ-CIA-023).
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __init__(self, donnees: Dict[str, Any]) -> None:
|
|
20
|
+
self.axes = ["radiance", "resistance", "lilith_variance", "shannon_entropy", "phi_ratio"]
|
|
21
|
+
self.valeurs = [float(donnees.get(axe, 0.0)) for axe in self.axes]
|
|
22
|
+
self.vecteur = self._encoder(donnees)
|
|
23
|
+
|
|
24
|
+
def _encoder(self, d: Dict[str, Any]) -> List[float]:
|
|
25
|
+
"""Convertit les métriques en vecteur normalisé pour la similitude cosinus."""
|
|
26
|
+
v = []
|
|
27
|
+
v.append(float(d.get("radiance", 0)) / 100.0)
|
|
28
|
+
v.append(min(1.0, float(d.get("resistance", 0))))
|
|
29
|
+
v.append(min(1.0, float(d.get("lilith_variance", 0)) / 1000.0))
|
|
30
|
+
v.append(min(1.0, float(d.get("shannon_entropy", 0)) / 10.0))
|
|
31
|
+
v.append(min(1.0, abs(float(d.get("phi_ratio", 0)) - PHI)))
|
|
32
|
+
return v
|
|
33
|
+
|
|
34
|
+
def transmuter(self) -> List[Dict[str, float]]:
|
|
35
|
+
"""
|
|
36
|
+
Transmutation Maat (EQ-BIN-010) : convertit chaque axe en coordonnée Z[φ].
|
|
37
|
+
a = ⌊val × 1000⌋ (Matière)
|
|
38
|
+
b = ⌊val × 1370⌋ (Phi - Résonance α⁻¹)
|
|
39
|
+
Retourne la résonance (a + bφ) × φ = b + (a+b)φ.
|
|
40
|
+
"""
|
|
41
|
+
coords = []
|
|
42
|
+
for val in self.valeurs:
|
|
43
|
+
a = math.floor(val * 1000)
|
|
44
|
+
b = math.floor(val * 1370)
|
|
45
|
+
coords.append({
|
|
46
|
+
"a": float(b),
|
|
47
|
+
"b": float(a + b)
|
|
48
|
+
})
|
|
49
|
+
return coords
|
|
50
|
+
|
|
51
|
+
def calculer_masse_harmonique(self) -> float:
|
|
52
|
+
"""Calcule la Masse Harmonique M_bit (EQ-BIN-003)."""
|
|
53
|
+
return sum(self.valeurs) / len(self.axes)
|
|
54
|
+
|
|
55
|
+
def calculer_coherence(self) -> float:
|
|
56
|
+
"""Calcule la Cohérence Interne C_bit (EQ-BIN-005)."""
|
|
57
|
+
stabilite_theo = 1.0 / PHI
|
|
58
|
+
moyenne = sum(v for v in self.valeurs if v > 0) / max(1, len(self.valeurs))
|
|
59
|
+
return (1.0 - abs(moyenne / 100.0 - stabilite_theo)) * 100.0
|
|
60
|
+
|
|
61
|
+
def calculer_similitude(self, autre: MatriceHolographique) -> float:
|
|
62
|
+
"""Calcule la similitude cosinus entre deux architectures holographiques."""
|
|
63
|
+
dot = sum(a * b for a, b in zip(self.vecteur, autre.vecteur))
|
|
64
|
+
norm_a = math.sqrt(sum(a*a for a in self.vecteur))
|
|
65
|
+
norm_b = math.sqrt(sum(b*b for b in autre.vecteur))
|
|
66
|
+
if norm_a == 0 or norm_b == 0:
|
|
67
|
+
return 0.0
|
|
68
|
+
return dot / (norm_a * norm_b)
|
|
69
|
+
|
|
70
|
+
def vers_grille(self) -> str:
|
|
71
|
+
"""Exporte la matrice sous forme de dôme de résonance transparent."""
|
|
72
|
+
res = " AXE | VALEUR | DÔME DE RÉSONANCE\n"
|
|
73
|
+
res += " ---------------|--------|------------------\n"
|
|
74
|
+
for i, axe in enumerate(self.axes):
|
|
75
|
+
intensite = "█" * int(self.vecteur[i] * 15)
|
|
76
|
+
res += f" {axe:<14} | {self.vecteur[i]:.4f} | {intensite}\n"
|
|
77
|
+
return res
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class RegistreAkashique:
|
|
81
|
+
"""
|
|
82
|
+
Gestionnaire souverain des Annales Akashiques.
|
|
83
|
+
Utilise le moteur de Matrice Holographique pour la navigation temporelle.
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
def __init__(self, workspace_root: str = ".") -> None:
|
|
87
|
+
self.phi_dir = os.path.join(workspace_root, ".phi")
|
|
88
|
+
self.db_path = os.path.join(self.phi_dir, "akasha.json")
|
|
89
|
+
self._initialiser_espace()
|
|
90
|
+
|
|
91
|
+
def _initialiser_espace(self) -> None:
|
|
92
|
+
if not os.path.exists(self.phi_dir):
|
|
93
|
+
os.makedirs(self.phi_dir)
|
|
94
|
+
if not os.path.exists(self.db_path):
|
|
95
|
+
with open(self.db_path, "w", encoding="utf-8") as f:
|
|
96
|
+
json.dump({"annales": [], "version": "11.6"}, f)
|
|
97
|
+
|
|
98
|
+
def enregistrer(self, resultat: Dict[str, Any]) -> None:
|
|
99
|
+
"""Archive un audit sous forme de signature holographique."""
|
|
100
|
+
try:
|
|
101
|
+
with open(self.db_path, "r", encoding="utf-8") as f:
|
|
102
|
+
data = json.load(f)
|
|
103
|
+
|
|
104
|
+
mat = MatriceHolographique(resultat)
|
|
105
|
+
evenement = {
|
|
106
|
+
"timestamp": time.time(),
|
|
107
|
+
"fichier": resultat.get("fichier", "inconnu"),
|
|
108
|
+
"radiance": resultat.get("radiance", 0),
|
|
109
|
+
"masse_harmonique": round(mat.calculer_masse_harmonique(), 4),
|
|
110
|
+
"coherence_c_bit": round(mat.calculer_coherence(), 2),
|
|
111
|
+
"coords_maat": mat.transmuter(),
|
|
112
|
+
"vecteur": mat.vecteur,
|
|
113
|
+
"signature": resultat.get("signature", "")
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
data["annales"].append(evenement)
|
|
117
|
+
if len(data["annales"]) > 1000:
|
|
118
|
+
data["annales"] = data["annales"][-1000:]
|
|
119
|
+
|
|
120
|
+
with open(self.db_path, "w", encoding="utf-8") as f:
|
|
121
|
+
json.dump(data, f, indent=2)
|
|
122
|
+
except Exception:
|
|
123
|
+
pass
|
|
124
|
+
|
|
125
|
+
def consulter_historique(self, limite: int = 7) -> List[Dict[str, Any]]:
|
|
126
|
+
"""Retourne les dernières annales."""
|
|
127
|
+
try:
|
|
128
|
+
with open(self.db_path, "r", encoding="utf-8") as f:
|
|
129
|
+
data = json.load(f)
|
|
130
|
+
return [dict(e) for e in data.get("annales", [])[-limite:]]
|
|
131
|
+
except Exception:
|
|
132
|
+
return []
|
|
133
|
+
|
|
134
|
+
def trouver_similitude(self, dictionnaire_cible: Dict[str, Any]) -> Optional[Dict[str, Any]]:
|
|
135
|
+
"""Recherche par proximité holographique (> 0.98 de gnose)."""
|
|
136
|
+
cible_mat = MatriceHolographique(dictionnaire_cible)
|
|
137
|
+
annales = self.consulter_historique(500)
|
|
138
|
+
|
|
139
|
+
meilleure_entree = None
|
|
140
|
+
max_sim = 0.98
|
|
141
|
+
|
|
142
|
+
for entry in annales:
|
|
143
|
+
if "vecteur" not in entry:
|
|
144
|
+
continue
|
|
145
|
+
if entry["fichier"] == dictionnaire_cible.get("fichier"):
|
|
146
|
+
continue
|
|
147
|
+
|
|
148
|
+
# Reconstruction de la matrice pour comparaison
|
|
149
|
+
pseudo_dict = {axe: val for axe, val in zip(cible_mat.axes, entry["vecteur"])}
|
|
150
|
+
mat_compare = MatriceHolographique(pseudo_dict)
|
|
151
|
+
mat_compare.vecteur = entry["vecteur"]
|
|
152
|
+
|
|
153
|
+
sim = cible_mat.calculer_similitude(mat_compare)
|
|
154
|
+
if sim > max_sim:
|
|
155
|
+
max_sim = sim
|
|
156
|
+
meilleure_entree = entry
|
|
157
|
+
|
|
158
|
+
return meilleure_entree
|