phi-complexity 0.2.1__tar.gz → 0.2.3__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.
Files changed (97) hide show
  1. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/PKG-INFO +292 -257
  2. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/README.md +255 -225
  3. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/__init__.py +100 -100
  4. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/__main__.py +5 -5
  5. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/akasha.py +166 -166
  6. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/analyseur.py +479 -479
  7. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/audit_slo.py +493 -493
  8. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/autosuture.py +79 -79
  9. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/backends/__init__.py +14 -14
  10. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/backends/asm_light.py +321 -321
  11. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/backends/base.py +21 -21
  12. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/backends/c_rust_light.py +239 -239
  13. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/backends/elf_light.py +728 -728
  14. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/backends/python.py +20 -20
  15. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/backup.py +62 -62
  16. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/bmad.py +144 -144
  17. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/canvas.py +174 -174
  18. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/cli.py +1251 -1092
  19. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/commit_risk.py +512 -512
  20. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/consensus.py +491 -491
  21. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/core.py +211 -176
  22. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/coverage_reporting.py +181 -181
  23. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/fingerprint.py +290 -290
  24. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/gnose.py +84 -84
  25. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/harvest.py +239 -239
  26. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/impossible.py +85 -85
  27. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/log_parser.py +343 -343
  28. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/metadata_ops.py +237 -237
  29. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/metriques.py +515 -498
  30. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/notebook_helpers.py +839 -839
  31. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/oracle.py +133 -133
  32. phi_complexity-0.2.3/phi_complexity/pipeline/__init__.py +5 -0
  33. phi_complexity-0.2.3/phi_complexity/pipeline/nodes.py +210 -0
  34. phi_complexity-0.2.3/phi_complexity/pipeline/orchestrator.py +237 -0
  35. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/rapport.py +234 -232
  36. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/remediation.py +241 -241
  37. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/search.py +245 -245
  38. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/securite.py +1313 -1132
  39. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/sentinel/__init__.py +42 -42
  40. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/sentinel/bayesian.py +314 -314
  41. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/sentinel/behavior.py +315 -315
  42. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/sentinel/host.py +323 -310
  43. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/sentinel/response.py +374 -374
  44. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/sentinel/telemetry.py +343 -343
  45. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/suture.py +118 -118
  46. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity/vault.py +304 -304
  47. phi_complexity-0.2.3/phi_complexity/web/__init__.py +3 -0
  48. phi_complexity-0.2.3/phi_complexity/web/server.py +169 -0
  49. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity.egg-info/PKG-INFO +292 -257
  50. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity.egg-info/SOURCES.txt +10 -1
  51. phi_complexity-0.2.3/phi_complexity.egg-info/requires.txt +11 -0
  52. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/pyproject.toml +103 -83
  53. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/setup.cfg +4 -4
  54. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_akasha.py +167 -167
  55. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_analyseur.py +603 -603
  56. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_asm_backend.py +382 -382
  57. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_audit_slo.py +573 -573
  58. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_autosuture.py +331 -331
  59. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_backends.py +417 -417
  60. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_backup.py +137 -137
  61. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_bmad.py +70 -70
  62. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_canvas.py +147 -147
  63. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_cli.py +778 -778
  64. phi_complexity-0.2.3/tests/test_cli_feedback.py +97 -0
  65. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_commit_risk.py +637 -637
  66. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_consensus.py +484 -484
  67. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_core.py +143 -143
  68. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_coverage_reporting.py +94 -94
  69. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_elf_backend.py +574 -574
  70. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_engine.py +305 -305
  71. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_fingerprint.py +298 -298
  72. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_gnose.py +116 -116
  73. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_harvest.py +263 -263
  74. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_impossible.py +103 -103
  75. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_log_parser.py +244 -244
  76. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_main.py +21 -21
  77. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_metadata_ops.py +230 -230
  78. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_metriques.py +434 -431
  79. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_notebook_helpers.py +689 -689
  80. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_oracle.py +160 -160
  81. phi_complexity-0.2.3/tests/test_phase34_coverage.py +215 -0
  82. phi_complexity-0.2.3/tests/test_pipeline.py +203 -0
  83. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_public_api_contract.py +29 -29
  84. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_rapport.py +162 -162
  85. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_remediation.py +219 -219
  86. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_scan_cli.py +332 -332
  87. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_search.py +306 -306
  88. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_securite.py +1348 -1203
  89. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_sentinel.py +804 -804
  90. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_suture.py +138 -138
  91. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/tests/test_vault.py +221 -221
  92. phi_complexity-0.2.3/tests/test_web_server.py +68 -0
  93. phi_complexity-0.2.1/phi_complexity.egg-info/requires.txt +0 -5
  94. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/LICENSE +0 -0
  95. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity.egg-info/dependency_links.txt +0 -0
  96. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity.egg-info/entry_points.txt +0 -0
  97. {phi_complexity-0.2.1 → phi_complexity-0.2.3}/phi_complexity.egg-info/top_level.txt +0 -0
@@ -1,257 +1,292 @@
1
- Metadata-Version: 2.4
2
- Name: phi-complexity
3
- Version: 0.2.1
4
- Summary: Code quality metrics based on Golden Ratio (φ) mathematical invariants
5
- Author-email: Tomy Verreault <Tiloup777@outlook.fr>
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: Programming Language :: Python :: 3.13
21
- Classifier: Programming Language :: Python :: 3.14
22
- Classifier: Topic :: Software Development :: Quality Assurance
23
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
- Requires-Python: >=3.9
25
- Description-Content-Type: text/markdown
26
- License-File: LICENSE
27
- Provides-Extra: notebooks
28
- Requires-Dist: jupyter; extra == "notebooks"
29
- Requires-Dist: matplotlib; extra == "notebooks"
30
- Requires-Dist: numpy; extra == "notebooks"
31
- Dynamic: license-file
32
-
33
- # phi-complexity
34
-
35
- > *Code quality metrics based on Golden Ratio (φ) mathematical invariants*
36
-
37
- [![PyPI version](https://img.shields.io/pypi/v/phi-complexity.svg)](https://pypi.org/project/phi-complexity/)
38
- [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
39
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/spockoo/phi-complexity/blob/main/LICENSE)
40
- [![Tests](https://img.shields.io/badge/tests-26%20passed-brightgreen)](https://github.com/spockoo/phi-complexity/tree/main/tests)
41
-
42
- `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...).
43
-
44
- Unlike `pylint` (cultural rules) or `radon` (McCabe metrics), `phi-complexity` answers:
45
-
46
- > *"Is this code in resonance with the natural laws of order, or is it collapsing under its own entropy?"*
47
-
48
- ---
49
-
50
- ## ⚡ Quick Start
51
-
52
- ```bash
53
- pip install phi-complexity
54
- ```
55
-
56
- ```bash
57
- # Audit a file
58
- phi check my_script.py
59
-
60
- # Audit a folder
61
- phi check ./src/
62
-
63
- # Generate a Markdown report
64
- phi report my_script.py --output report.md
65
-
66
- # CI/CD strict mode (exit 1 if radiance < 75)
67
- phi check ./src/ --min-radiance 75
68
- ```
69
-
70
- ### Python API
71
-
72
- ```python
73
- from phi_complexity import auditer, rapport_console, rapport_markdown
74
-
75
- # Get metrics as a dict
76
- metrics = auditer("my_script.py")
77
- print(metrics["radiance"]) # → 82.4
78
- print(metrics["statut_gnostique"]) # → "EN ÉVEIL ◈"
79
- print(metrics["oudjat"]) # → {"nom": "process_data", "ligne": 42, ...}
80
-
81
- # Print console report
82
- print(rapport_console("my_script.py"))
83
-
84
- # Save Markdown report
85
- rapport_markdown("my_script.py", sortie="report.md")
86
- ```
87
-
88
- ---
89
-
90
- ## 📊 Metrics
91
-
92
- | Metric | Description | Mathematical basis |
93
- |---|---|---|
94
- | **Radiance Score** | Global quality score (0–100) | `100 - f(Lilith) - g(H) - h(Anomalies) - i(Fib)` |
95
- | **Variance de Lilith** | Structural instability | Population variance of function complexities |
96
- | **Shannon Entropy** | Information density | `H = -Σ p·log₂(p)` |
97
- | **φ-Ratio** | Dominant function ratio | `max_complexity / mean` → should tend toward φ |
98
- | **Fibonacci Distance** | Natural size alignment | `Σ|n_i - Fib_k| / φ` |
99
- | **Zeta-Score** | Global resonance | `ζ_meta(functions, φ)` converging series |
100
-
101
- ### Gnostic Status Levels
102
-
103
- | Score | Status | Meaning |
104
- |---|---|---|
105
- | ≥ 85 | **HERMÉTIQUE ✦** | Stable, harmonious, production-ready |
106
- | 60–84 | **EN ÉVEIL ◈** | Potential exists, some entropy zones |
107
- | < 60 | **DORMANT ░** | Deep restructuring recommended |
108
-
109
- ---
110
-
111
- ## 🧭 Command Stability Matrix
112
-
113
- | Command | Stability | Purpose | Output / Side-effects |
114
- |---|---|---|---|
115
- | `phi check` | **Stable** | Audit radiance for files/folders | Console or JSON (no writes) |
116
- | `phi report` | **Stable** | Markdown report | Writes `report.md` if `--output` |
117
- | `phi oracle` | **Stable** | Release gate (radiance + tests) | Console; exits 1 on failure |
118
- | `phi harvest` | Experimental | AST vectors collection | Writes `.phi/harvest.jsonl` |
119
- | `phi metadata` | Experimental | Metadata summary & purge (harvest/vault) | Summaries; sanitized JSONL |
120
- | `phi vault` / `phi graph` / `phi canvas` | Experimental | Vault storage + graph export + Obsidian canvas | Writes under `.phi/` (JSON, DOT/ASCII, `.canvas`) |
121
- | `phi search` | Experimental | Query the vault | Console/JSON; reads `.phi/vault.jsonl` |
122
- | `phi seal` / `phi heal` | Experimental | Seal + auto-suture via LLM | May call local LLM (`--url`); writes seal metadata in `.phi/` |
123
- | `phi spiral` | Experimental | Radiance spiral visualization | Console ASCII only |
124
-
125
- **Tip:** keep `phi check`/`phi report`/`phi oracle` in CI. Use experimental commands locally first and pin outputs under `.phi/` in `.gitignore` if not needed in VCS.
126
-
127
- ---
128
-
129
- ## 🔍 Sample Output
130
-
131
- ```
132
- ╔══════════════════════════════════════════════════╗
133
- ║ PHI-COMPLEXITY — AUDIT DE RADIANCE ║
134
- ╚══════════════════════════════════════════════════╝
135
-
136
- 📄 Fichier : my_script.py
137
- 📅 Date : 2026-04-08 17:11
138
-
139
- ☼ RADIANCE : ██████████████░░░░░░ 72.6 / 100
140
- ⚖ LILITH : 11221.9 (Structural variance)
141
- 🌊 ENTROPIE : 2.48 bits (Shannon)
142
- ◈ PHI-RATIO : 3.43 (ideal: φ = 1.618, Δ=1.81)
143
- ζ ZETA-SCORE : 0.3656 (Global resonance)
144
-
145
- STATUT : EN ÉVEIL ◈
146
-
147
- 🔎 OUDJAT : 'process_data' (Line 42, Complexity: 376)
148
-
149
- ⚠ SUTURES IDENTIFIED (2):
150
- 🟡 Line 18 [LILITH] : Nested loop (depth 2). Consider a helper function.
151
- >> for j in range(b):
152
- 🔵 Line 67 [SOUVERAINETE] : 'load_data' receives 6 arguments. Encapsulate in an object.
153
- >> def load_data(path, sep, enc, cols, dtype, na):
154
- ```
155
-
156
- ---
157
-
158
- ## 🚀 CI Innovation Suite (Open Source)
159
-
160
- `phi-complexity` embarque maintenant une suite orientée productivité/dev/ops :
161
-
162
- - **AI AutoFix Studio** : règles de mutation déterministes pour appliquer rapidement des corrections CI.
163
- - **Flow Intelligence** : classification dédiée des annulations liées à la concurrence (`WORKFLOW_CONCURRENCY_CANCELLED`).
164
- - **Runner Sentinel** : détection explicite des blocages de queue runner (`RUNNER_QUEUE_STALL`).
165
- - **Ops & Engineering Control Plane** : snapshot exportable JSON/Markdown (succès/échecs/cancelled, MTTR, causes racines, tendances).
166
- - **Dev Productivity Environment** : `.devcontainer` + `Makefile` + commande `make ci-local` pour reproduire le pipeline localement.
167
-
168
- ```bash
169
- make setup
170
- make ci-local
171
- ```
172
-
173
- ---
174
-
175
- ## 🧮 Mathematical Foundations
176
-
177
- The **Radiance Formula** is derived from:
178
-
179
- - **φ-Meta Framework** (Tomy Verreault, 2026) — Axioms AX-A0 through AX-A58
180
- - **Law of Antifragility** (EQ-AFR-BMAD): `φ_{t+1} = P_φ(φ_t + k·Var(E_t)·E_t)`
181
- - **Cybernetics** (Korchounov, Mir, 1975) — Feedback and variance as control metrics
182
- - **Shannon Information Theory** — Code as an information channel
183
-
184
- The **Sovereign Coding Rules** are derived from:
185
- - **The C Book** (Banahan, Brady, Doran) — Scope hermeticity, resource lifecycle
186
- - **JaCaMo / Multi-Agent Programming** — Agent independence and encapsulation
187
-
188
- Full mathematical proof: [docs/MATHEMATIQUES.md](https://github.com/spockoo/phi-complexity/blob/main/docs/MATHEMATIQUES.md)
189
-
190
- ---
191
-
192
- ## 🏗 Sovereign Architecture
193
-
194
- ```
195
- Zero external dependencies.
196
- Pure Python standard library (ast, math, json).
197
- ```
198
-
199
- ```
200
- phi_complexity/
201
- ├── core.py ← Golden constants (PHI, TAXE_SUTURE, ETA_GOLDEN...)
202
- ├── analyseur.py ← AST fractal dissection
203
- ├── metriques.py ← Radiance Index calculation
204
- ├── rapport.py ← Console / Markdown / JSON rendering
205
- └── cli.py ← phi check / phi report
206
- ```
207
-
208
- ---
209
-
210
- ## 🔗 Integration
211
-
212
- ### Pre-commit Hook
213
- ```yaml
214
- repos:
215
- - repo: https://github.com/spockoo/phi-complexity
216
- rev: v0.1.0
217
- hooks:
218
- - id: phi-check
219
- args: [--min-radiance, "70"]
220
- ```
221
-
222
- ### GitHub Action
223
- ```yaml
224
- - name: Phi-Complexity Audit
225
- run: |
226
- pip install phi-complexity
227
- phi check ./src/ --min-radiance 75
228
- ```
229
-
230
- ### Secrets (`ADMIN_TOKEN`)
231
-
232
- - Never commit `ADMIN_TOKEN` in tracked files.
233
- - Store it in environment variables or GitHub Actions Secrets.
234
- - Use `.env.example` as a template only:
235
-
236
- ```dotenv
237
- ADMIN_TOKEN=
238
- ```
239
-
240
- ---
241
-
242
- ## 📜 License
243
-
244
- MIT — Tomy Verreault, 2026
245
-
246
- *Anchored in the Bibliothèque Céleste — Morphic Phi Framework (φ-Meta)*
247
-
248
- ## 🔒 Sécurité : Activation du contrôle phi-check
249
-
250
- Ce projet utilise un contrôle automatique (pré-commit) qui bloque tout ajout de code contenant certains mots ou outils réservés (par exemple des scripts ou outils reconnus de piratage).
251
-
252
- **Pour installer et activer le contrôle localement :**
253
- ```sh
254
- pip install pre-commit
255
- pre-commit install
256
- ```
257
- Le contrôle `phi-check` se lance alors automatiquement à chaque commit.
1
+ Metadata-Version: 2.4
2
+ Name: phi-complexity
3
+ Version: 0.2.3
4
+ Summary: Code quality metrics based on Golden Ratio (φ) mathematical invariants
5
+ Author-email: Tomy Verreault <Tiloup777@outlook.fr>
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: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Software Development :: Quality Assurance
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Provides-Extra: notebooks
28
+ Requires-Dist: jupyter; extra == "notebooks"
29
+ Requires-Dist: matplotlib; extra == "notebooks"
30
+ Requires-Dist: numpy; extra == "notebooks"
31
+ Provides-Extra: web
32
+ Requires-Dist: fastapi; extra == "web"
33
+ Requires-Dist: uvicorn; extra == "web"
34
+ Requires-Dist: websockets; extra == "web"
35
+ Requires-Dist: jinja2; extra == "web"
36
+ Dynamic: license-file
37
+
38
+ # phi-complexity
39
+
40
+ > *Code quality metrics based on Golden Ratio (φ) mathematical invariants*
41
+
42
+ [![PyPI version](https://img.shields.io/pypi/v/phi-complexity.svg)](https://pypi.org/project/phi-complexity/)
43
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
44
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/spockoo/phi-complexity/blob/main/LICENSE)
45
+ [![Tests](https://img.shields.io/badge/tests-26%20passed-brightgreen)](https://github.com/spockoo/phi-complexity/tree/main/tests)
46
+
47
+ `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...).
48
+
49
+ Unlike `pylint` (cultural rules) or `radon` (McCabe metrics), `phi-complexity` answers:
50
+
51
+ > *"Is this code in resonance with the natural laws of order, or is it collapsing under its own entropy?"*
52
+
53
+ ---
54
+
55
+ ## ⚡ Quick Start
56
+
57
+ ```bash
58
+ pip install phi-complexity
59
+ ```
60
+
61
+ ```bash
62
+ # Audit a file
63
+ phi check my_script.py
64
+
65
+ # Audit a folder
66
+ phi check ./src/
67
+
68
+ # Start the Sovereign Web IDE (Local-First browser interface)
69
+ phi ui
70
+
71
+ # Generate a Markdown report
72
+ phi report my_script.py --output report.md
73
+
74
+ # CI/CD strict mode (exit 1 if radiance < 75)
75
+ phi check ./src/ --min-radiance 75
76
+ ```
77
+
78
+ ### Python API
79
+
80
+ ```python
81
+ from phi_complexity import auditer, rapport_console, rapport_markdown
82
+
83
+ # Get metrics as a dict
84
+ metrics = auditer("my_script.py")
85
+ print(metrics["radiance"]) # → 82.4
86
+ print(metrics["statut_gnostique"]) # → "EN ÉVEIL ◈"
87
+ print(metrics["oudjat"]) # → {"nom": "process_data", "ligne": 42, ...}
88
+
89
+ # Print console report
90
+ print(rapport_console("my_script.py"))
91
+
92
+ # Save Markdown report
93
+ rapport_markdown("my_script.py", sortie="report.md")
94
+ ```
95
+
96
+ ---
97
+
98
+ ## 📊 Metrics
99
+
100
+ | Metric | Description | Mathematical basis |
101
+ |---|---|---|
102
+ | **Radiance Score** | Global quality score (0–100) | `100 - f(Lilith) - g(H) - h(Anomalies) - i(Fib)` |
103
+ | **Variance de Lilith** | Structural instability | Population variance of function complexities |
104
+ | **Shannon Entropy** | Information density | `H = -Σ p·log₂(p)` |
105
+ | **φ-Ratio** | Dominant function ratio | `max_complexity / mean` → should tend toward φ |
106
+ | **Fibonacci Distance** | Natural size alignment | `Σ|n_i - Fib_k| / φ` |
107
+ | **Zeta-Score** | Global resonance | `ζ_meta(functions, φ)` converging series |
108
+
109
+ ### Gnostic Status Levels
110
+
111
+ | Score | Status | Meaning |
112
+ |---|---|---|
113
+ | ≥ 85 | **HERMÉTIQUE ✦** | Stable, harmonious, production-ready |
114
+ | 60–84 | **EN ÉVEIL ◈** | Potential exists, some entropy zones |
115
+ | < 60 | **DORMANT ░** | Deep restructuring recommended |
116
+
117
+ ---
118
+
119
+ ## 🧭 Command Stability Matrix
120
+
121
+ | Command | Stability | Purpose | Output / Side-effects |
122
+ |---|---|---|---|
123
+ | `phi check` | **Stable** | Audit radiance for files/folders | Console (Aesthetic v0.1.0) or JSON |
124
+ | `phi ui` | **Stable** | Launch Local-First Web IDE | Starts Uvicorn server + opens browser |
125
+ | `phi report` | **Stable** | Markdown report | Writes `report.md` if `--output` |
126
+ | `phi oracle` | **Stable** | Release gate (radiance + tests) | Console; exits 1 on failure |
127
+ | `phi harvest` | Experimental | AST vectors collection | Writes `.phi/harvest.jsonl` |
128
+ | `phi metadata` | Experimental | Metadata summary & purge (harvest/vault) | Summaries; sanitized JSONL |
129
+ | `phi vault` / `phi graph` / `phi canvas` | Experimental | Vault storage + graph export + Obsidian canvas | Writes under `.phi/` (JSON, DOT/ASCII, `.canvas`) |
130
+ | `phi search` | Experimental | Query the vault | Console/JSON; reads `.phi/vault.jsonl` |
131
+ | `phi seal` / `phi heal` | Experimental | Seal + auto-suture via LLM | May call local LLM (`--url`); writes seal metadata in `.phi/` |
132
+ | `phi spiral` | Experimental | Radiance spiral visualization | Console ASCII only |
133
+
134
+ **Tip:** keep `phi check`/`phi report`/`phi oracle` in CI. Use experimental commands locally first and pin outputs under `.phi/` in `.gitignore` if not needed in VCS.
135
+
136
+ ---
137
+
138
+ ## 🔍 Sample Output
139
+
140
+ ```
141
+ ╔══════════════════════════════════════════════════╗
142
+ ║ PHI-COMPLEXITY — AUDIT DE RADIANCE ║
143
+ ╚══════════════════════════════════════════════════╝
144
+
145
+ 📄 Fichier : my_script.py
146
+ 📅 Date : 2026-04-08 17:11
147
+
148
+ ☼ RADIANCE : ██████████████░░░░░░ 72.6 / 100
149
+ ⚖ LILITH : 11221.9 (Structural variance)
150
+ 🌊 ENTROPIE : 2.48 bits (Shannon)
151
+ ◈ PHI-RATIO : 3.43 (ideal: φ = 1.618, Δ=1.81)
152
+ ζ ZETA-SCORE : 0.3656 (Global resonance)
153
+
154
+ STATUT : EN ÉVEIL ◈
155
+
156
+ 🔎 OUDJAT : 'process_data' (Line 42, Complexity: 376)
157
+
158
+ ⚠ SUTURES IDENTIFIED (2):
159
+ 🟡 Line 18 [LILITH] : Nested loop (depth 2). Consider a helper function.
160
+ >> for j in range(b):
161
+ 🔵 Line 67 [SOUVERAINETE] : 'load_data' receives 6 arguments. Encapsulate in an object.
162
+ >> def load_data(path, sep, enc, cols, dtype, na):
163
+ ```
164
+
165
+ ---
166
+
167
+ ## 🚀 Phidélia Cyber Station (Web IDE)
168
+
169
+ `phi-complexity` dispose maintenant (via les dépendances `[web]`) d'un véritable **IDE Web Local Souverain** (`phi ui`), fonctionnant intégralement en local avec communication WebSockets :
170
+ - **Glassmorphism & Néon** : Design premium ultra-soigné et sans dépendances JS externes (Vanilla JS/CSS).
171
+ - **Monaco Editor** : Le moteur haute-performance derrière VS Code, intégré hors ligne.
172
+ - **WebSocket Streaming** : Dialogue asynchrone direct entre l'orchestrateur Python et le frontend.
173
+
174
+ ---
175
+
176
+ ## 🚀 CI Innovation Suite (Open Source)
177
+
178
+ `phi-complexity` embarque maintenant une suite orientée productivité/dev/ops :
179
+
180
+ - **AI AutoFix Studio** : règles de mutation déterministes pour appliquer rapidement des corrections CI.
181
+ - **Flow Intelligence** : classification dédiée des annulations liées à la concurrence (`WORKFLOW_CONCURRENCY_CANCELLED`).
182
+ - **Runner Sentinel** : détection explicite des blocages de queue runner (`RUNNER_QUEUE_STALL`).
183
+ - **Ops & Engineering Control Plane** : snapshot exportable JSON/Markdown (succès/échecs/cancelled, MTTR, causes racines, tendances).
184
+ - **Dev Productivity Environment** : `.devcontainer` + `Makefile` + commande `make ci-local` pour reproduire le pipeline localement.
185
+
186
+ ```bash
187
+ make setup
188
+ make ci-local
189
+ ```
190
+
191
+ ---
192
+
193
+ ## 🧮 Mathematical Foundations
194
+
195
+ The **Radiance Formula** is derived from:
196
+
197
+ - **φ-Meta Framework** (Tomy Verreault, 2026) — Axioms AX-A0 through AX-A58
198
+ - **Law of Antifragility** (EQ-AFR-BMAD): `φ_{t+1} = P_φ(φ_t + k·Var(E_t)·E_t)`
199
+ - **Cybernetics** (Korchounov, Mir, 1975) — Feedback and variance as control metrics
200
+ - **Shannon Information Theory** — Code as an information channel
201
+
202
+ The **Sovereign Coding Rules** are derived from:
203
+ - **The C Book** (Banahan, Brady, Doran) — Scope hermeticity, resource lifecycle
204
+ - **JaCaMo / Multi-Agent Programming** — Agent independence and encapsulation
205
+
206
+ Full mathematical proof: [docs/MATHEMATIQUES.md](https://github.com/spockoo/phi-complexity/blob/main/docs/MATHEMATIQUES.md)
207
+
208
+ ---
209
+
210
+ ## 🏗 Sovereign Architecture
211
+
212
+ ```
213
+ Zero external dependencies.
214
+ Pure Python standard library (ast, math, json).
215
+ ```
216
+
217
+ ```
218
+ phi_complexity/
219
+ ├── core.py ← Golden constants (PHI, TAXE_SUTURE, ETA_GOLDEN...)
220
+ ├── analyseur.py ← AST fractal dissection
221
+ ├── metriques.py ← Radiance Index calculation
222
+ ├── rapport.py ← Console / Markdown / JSON rendering
223
+ └── cli.py ← phi check / phi report
224
+ ```
225
+
226
+ ---
227
+
228
+ ## 🔗 Integration
229
+
230
+ ### Pre-commit Hook
231
+ ```yaml
232
+ repos:
233
+ - repo: https://github.com/spockoo/phi-complexity
234
+ rev: v0.1.0
235
+ hooks:
236
+ - id: phi-check
237
+ args: [--min-radiance, "70"]
238
+ ```
239
+
240
+ ### GitHub Action
241
+ ```yaml
242
+ - name: Phi-Complexity Audit
243
+ run: |
244
+ pip install phi-complexity
245
+ phi check ./src/ --min-radiance 75
246
+ ```
247
+
248
+ ### Secrets (`ADMIN_TOKEN`)
249
+
250
+ - Never commit `ADMIN_TOKEN` in tracked files.
251
+ - Store it in environment variables or GitHub Actions Secrets.
252
+ - Use `.env.example` as a template only:
253
+
254
+ ```dotenv
255
+ ADMIN_TOKEN=
256
+ ```
257
+
258
+ ---
259
+
260
+ ## 📜 License
261
+
262
+ MIT — Tomy Verreault, 2026
263
+
264
+ *Anchored in the Bibliothèque Céleste — Morphic Phi Framework (φ-Meta)*
265
+
266
+ ## 📜 Historique des Versions (Changelog)
267
+
268
+ - **v0.2.3 (FastAPI & Phidélia Station) — Actuelle** :
269
+ - **Lancement de l'IDE Web souverain** : Nouveau point d'entrée `phi ui` qui déploie un orchestrateur local avec frontend premium (Monaco Editor, WebSockets, Vanilla JS).
270
+ - Restauration minutieuse de l'esthétique absolue de la `v0.1.0` pour les rapports `phi check` dans la console.
271
+
272
+ - **v0.2.2 (Souveraineté & Cybersécurité)** :
273
+ - Implémentation du **"Cerveau de Sécurité"** : Moteur de triage mathématique départageant les failles critiques cybernétiques (CWE-79, CWE-89) des simples anomalies architecturales (Variance Lilith, Complexité).
274
+ - Algorithmes de **Mémoire Fail-Fast** pour `phi_check` optimisant à 100% le temps processeur et la RAM lors des audits anti-mots-interdits.
275
+ - Conformité CI parfaite garantissant aucune friction entre Windows et Linux (via normalisation PEP8 stricte).
276
+
277
+ - **v0.2.1** : Intégration souveraine du `phi_check` pré-commit natif et de la politique `Quality Gate` pour GitHub Actions. Réparation des métriques de base.
278
+ - **v0.2.0** : Introduction de pydantic pour la vérification de la robustesse, ajouts de structures initiales pour les métriques `Souverainete`.
279
+ - **v0.1.0** : Version primaire. Formule mathématique de base implémentée (Lilith, Shannon, Fib, Radiance).
280
+
281
+ ---
282
+
283
+ ## 🔒 Sécurité : Activation du contrôle phi-check
284
+
285
+ Ce projet utilise un contrôle automatique (pré-commit) qui bloque tout ajout de code contenant certains mots ou outils réservés (par exemple des scripts ou outils reconnus de piratage).
286
+
287
+ **Pour installer et activer le contrôle localement :**
288
+ ```sh
289
+ pip install pre-commit
290
+ pre-commit install
291
+ ```
292
+ Le contrôle `phi-check` se lance alors automatiquement à chaque commit.