phi-complexity 0.1.3__tar.gz → 0.2.1__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 (95) hide show
  1. {phi_complexity-0.1.3 → phi_complexity-0.2.1}/PKG-INFO +64 -2
  2. {phi_complexity-0.1.3 → phi_complexity-0.2.1}/README.md +225 -169
  3. phi_complexity-0.2.1/phi_complexity/__init__.py +100 -0
  4. {phi_complexity-0.1.3 → phi_complexity-0.2.1}/phi_complexity/__main__.py +5 -3
  5. phi_complexity-0.2.1/phi_complexity/akasha.py +166 -0
  6. phi_complexity-0.2.1/phi_complexity/analyseur.py +479 -0
  7. phi_complexity-0.2.1/phi_complexity/audit_slo.py +493 -0
  8. phi_complexity-0.2.1/phi_complexity/autosuture.py +79 -0
  9. phi_complexity-0.2.1/phi_complexity/backends/__init__.py +14 -0
  10. phi_complexity-0.2.1/phi_complexity/backends/asm_light.py +321 -0
  11. phi_complexity-0.2.1/phi_complexity/backends/base.py +21 -0
  12. phi_complexity-0.2.1/phi_complexity/backends/c_rust_light.py +239 -0
  13. phi_complexity-0.2.1/phi_complexity/backends/elf_light.py +728 -0
  14. phi_complexity-0.2.1/phi_complexity/backends/python.py +20 -0
  15. phi_complexity-0.2.1/phi_complexity/backup.py +62 -0
  16. phi_complexity-0.2.1/phi_complexity/bmad.py +144 -0
  17. phi_complexity-0.2.1/phi_complexity/canvas.py +174 -0
  18. phi_complexity-0.2.1/phi_complexity/cli.py +1092 -0
  19. phi_complexity-0.2.1/phi_complexity/commit_risk.py +512 -0
  20. phi_complexity-0.2.1/phi_complexity/consensus.py +491 -0
  21. phi_complexity-0.2.1/phi_complexity/core.py +176 -0
  22. phi_complexity-0.2.1/phi_complexity/coverage_reporting.py +181 -0
  23. phi_complexity-0.2.1/phi_complexity/fingerprint.py +290 -0
  24. phi_complexity-0.2.1/phi_complexity/gnose.py +84 -0
  25. phi_complexity-0.2.1/phi_complexity/harvest.py +239 -0
  26. phi_complexity-0.2.1/phi_complexity/impossible.py +85 -0
  27. phi_complexity-0.2.1/phi_complexity/log_parser.py +343 -0
  28. phi_complexity-0.2.1/phi_complexity/metadata_ops.py +237 -0
  29. phi_complexity-0.2.1/phi_complexity/metriques.py +498 -0
  30. phi_complexity-0.2.1/phi_complexity/notebook_helpers.py +839 -0
  31. phi_complexity-0.2.1/phi_complexity/oracle.py +133 -0
  32. {phi_complexity-0.1.3 → phi_complexity-0.2.1}/phi_complexity/rapport.py +232 -166
  33. phi_complexity-0.2.1/phi_complexity/remediation.py +241 -0
  34. phi_complexity-0.2.1/phi_complexity/search.py +245 -0
  35. phi_complexity-0.2.1/phi_complexity/securite.py +1132 -0
  36. phi_complexity-0.2.1/phi_complexity/sentinel/__init__.py +42 -0
  37. phi_complexity-0.2.1/phi_complexity/sentinel/bayesian.py +314 -0
  38. phi_complexity-0.2.1/phi_complexity/sentinel/behavior.py +315 -0
  39. phi_complexity-0.2.1/phi_complexity/sentinel/host.py +310 -0
  40. phi_complexity-0.2.1/phi_complexity/sentinel/response.py +374 -0
  41. phi_complexity-0.2.1/phi_complexity/sentinel/telemetry.py +343 -0
  42. phi_complexity-0.2.1/phi_complexity/suture.py +118 -0
  43. phi_complexity-0.2.1/phi_complexity/vault.py +304 -0
  44. {phi_complexity-0.1.3 → phi_complexity-0.2.1}/phi_complexity.egg-info/PKG-INFO +64 -2
  45. phi_complexity-0.2.1/phi_complexity.egg-info/SOURCES.txt +85 -0
  46. phi_complexity-0.2.1/phi_complexity.egg-info/requires.txt +5 -0
  47. {phi_complexity-0.1.3 → phi_complexity-0.2.1}/pyproject.toml +83 -44
  48. phi_complexity-0.2.1/tests/test_akasha.py +167 -0
  49. phi_complexity-0.2.1/tests/test_analyseur.py +603 -0
  50. phi_complexity-0.2.1/tests/test_asm_backend.py +382 -0
  51. phi_complexity-0.2.1/tests/test_audit_slo.py +573 -0
  52. phi_complexity-0.2.1/tests/test_autosuture.py +331 -0
  53. phi_complexity-0.2.1/tests/test_backends.py +417 -0
  54. phi_complexity-0.2.1/tests/test_backup.py +137 -0
  55. phi_complexity-0.2.1/tests/test_bmad.py +70 -0
  56. phi_complexity-0.2.1/tests/test_canvas.py +147 -0
  57. phi_complexity-0.2.1/tests/test_cli.py +778 -0
  58. phi_complexity-0.2.1/tests/test_commit_risk.py +637 -0
  59. phi_complexity-0.2.1/tests/test_consensus.py +484 -0
  60. {phi_complexity-0.1.3 → phi_complexity-0.2.1}/tests/test_core.py +143 -92
  61. phi_complexity-0.2.1/tests/test_coverage_reporting.py +94 -0
  62. phi_complexity-0.2.1/tests/test_elf_backend.py +574 -0
  63. phi_complexity-0.2.1/tests/test_engine.py +305 -0
  64. phi_complexity-0.2.1/tests/test_fingerprint.py +298 -0
  65. phi_complexity-0.2.1/tests/test_gnose.py +116 -0
  66. phi_complexity-0.2.1/tests/test_harvest.py +263 -0
  67. phi_complexity-0.2.1/tests/test_impossible.py +103 -0
  68. phi_complexity-0.2.1/tests/test_log_parser.py +244 -0
  69. phi_complexity-0.2.1/tests/test_main.py +21 -0
  70. phi_complexity-0.2.1/tests/test_metadata_ops.py +230 -0
  71. phi_complexity-0.2.1/tests/test_metriques.py +431 -0
  72. phi_complexity-0.2.1/tests/test_notebook_helpers.py +689 -0
  73. phi_complexity-0.2.1/tests/test_oracle.py +160 -0
  74. phi_complexity-0.2.1/tests/test_public_api_contract.py +29 -0
  75. {phi_complexity-0.1.3 → phi_complexity-0.2.1}/tests/test_rapport.py +162 -147
  76. phi_complexity-0.2.1/tests/test_remediation.py +219 -0
  77. phi_complexity-0.2.1/tests/test_scan_cli.py +332 -0
  78. phi_complexity-0.2.1/tests/test_search.py +306 -0
  79. phi_complexity-0.2.1/tests/test_securite.py +1203 -0
  80. phi_complexity-0.2.1/tests/test_sentinel.py +804 -0
  81. phi_complexity-0.2.1/tests/test_suture.py +138 -0
  82. phi_complexity-0.2.1/tests/test_vault.py +221 -0
  83. phi_complexity-0.1.3/phi_complexity/__init__.py +0 -65
  84. phi_complexity-0.1.3/phi_complexity/analyseur.py +0 -281
  85. phi_complexity-0.1.3/phi_complexity/cli.py +0 -183
  86. phi_complexity-0.1.3/phi_complexity/core.py +0 -65
  87. phi_complexity-0.1.3/phi_complexity/metriques.py +0 -206
  88. phi_complexity-0.1.3/phi_complexity.egg-info/SOURCES.txt +0 -19
  89. phi_complexity-0.1.3/tests/test_analyseur.py +0 -204
  90. phi_complexity-0.1.3/tests/test_cli.py +0 -163
  91. {phi_complexity-0.1.3 → phi_complexity-0.2.1}/LICENSE +0 -0
  92. {phi_complexity-0.1.3 → phi_complexity-0.2.1}/phi_complexity.egg-info/dependency_links.txt +0 -0
  93. {phi_complexity-0.1.3 → phi_complexity-0.2.1}/phi_complexity.egg-info/entry_points.txt +0 -0
  94. {phi_complexity-0.1.3 → phi_complexity-0.2.1}/phi_complexity.egg-info/top_level.txt +0 -0
  95. {phi_complexity-0.1.3 → phi_complexity-0.2.1}/setup.cfg +0 -0
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: phi-complexity
3
- Version: 0.1.3
3
+ Version: 0.2.1
4
4
  Summary: Code quality metrics based on Golden Ratio (φ) mathematical invariants
5
- Author-email: Tomy Verreault <contact@phidelia.dev>
5
+ Author-email: Tomy Verreault <Tiloup777@outlook.fr>
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://github.com/spockoo/phi-complexity
8
8
  Project-URL: Repository, https://github.com/spockoo/phi-complexity
@@ -17,11 +17,17 @@ Classifier: Programming Language :: Python :: 3.9
17
17
  Classifier: Programming Language :: Python :: 3.10
18
18
  Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
20
22
  Classifier: Topic :: Software Development :: Quality Assurance
21
23
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
24
  Requires-Python: >=3.9
23
25
  Description-Content-Type: text/markdown
24
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"
25
31
  Dynamic: license-file
26
32
 
27
33
  # phi-complexity
@@ -102,6 +108,24 @@ rapport_markdown("my_script.py", sortie="report.md")
102
108
 
103
109
  ---
104
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
+
105
129
  ## 🔍 Sample Output
106
130
 
107
131
  ```
@@ -131,6 +155,23 @@ rapport_markdown("my_script.py", sortie="report.md")
131
155
 
132
156
  ---
133
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
+
134
175
  ## 🧮 Mathematical Foundations
135
176
 
136
177
  The **Radiance Formula** is derived from:
@@ -186,6 +227,16 @@ repos:
186
227
  phi check ./src/ --min-radiance 75
187
228
  ```
188
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
+
189
240
  ---
190
241
 
191
242
  ## 📜 License
@@ -193,3 +244,14 @@ repos:
193
244
  MIT — Tomy Verreault, 2026
194
245
 
195
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,169 +1,225 @@
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)](https://github.com/spockoo/phi-complexity/blob/main/LICENSE)
8
- [![Tests](https://img.shields.io/badge/tests-26%20passed-brightgreen)](https://github.com/spockoo/phi-complexity/tree/main/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](https://github.com/spockoo/phi-complexity/blob/main/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)*
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)](https://github.com/spockoo/phi-complexity/blob/main/LICENSE)
8
+ [![Tests](https://img.shields.io/badge/tests-26%20passed-brightgreen)](https://github.com/spockoo/phi-complexity/tree/main/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
+ ## 🧭 Command Stability Matrix
80
+
81
+ | Command | Stability | Purpose | Output / Side-effects |
82
+ |---|---|---|---|
83
+ | `phi check` | **Stable** | Audit radiance for files/folders | Console or JSON (no writes) |
84
+ | `phi report` | **Stable** | Markdown report | Writes `report.md` if `--output` |
85
+ | `phi oracle` | **Stable** | Release gate (radiance + tests) | Console; exits 1 on failure |
86
+ | `phi harvest` | Experimental | AST vectors collection | Writes `.phi/harvest.jsonl` |
87
+ | `phi metadata` | Experimental | Metadata summary & purge (harvest/vault) | Summaries; sanitized JSONL |
88
+ | `phi vault` / `phi graph` / `phi canvas` | Experimental | Vault storage + graph export + Obsidian canvas | Writes under `.phi/` (JSON, DOT/ASCII, `.canvas`) |
89
+ | `phi search` | Experimental | Query the vault | Console/JSON; reads `.phi/vault.jsonl` |
90
+ | `phi seal` / `phi heal` | Experimental | Seal + auto-suture via LLM | May call local LLM (`--url`); writes seal metadata in `.phi/` |
91
+ | `phi spiral` | Experimental | Radiance spiral visualization | Console ASCII only |
92
+
93
+ **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.
94
+
95
+ ---
96
+
97
+ ## 🔍 Sample Output
98
+
99
+ ```
100
+ ╔══════════════════════════════════════════════════╗
101
+ ║ PHI-COMPLEXITY — AUDIT DE RADIANCE ║
102
+ ╚══════════════════════════════════════════════════╝
103
+
104
+ 📄 Fichier : my_script.py
105
+ 📅 Date : 2026-04-08 17:11
106
+
107
+ ☼ RADIANCE : ██████████████░░░░░░ 72.6 / 100
108
+ ⚖ LILITH : 11221.9 (Structural variance)
109
+ 🌊 ENTROPIE : 2.48 bits (Shannon)
110
+ ◈ PHI-RATIO : 3.43 (ideal: φ = 1.618, Δ=1.81)
111
+ ζ ZETA-SCORE : 0.3656 (Global resonance)
112
+
113
+ STATUT : EN ÉVEIL ◈
114
+
115
+ 🔎 OUDJAT : 'process_data' (Line 42, Complexity: 376)
116
+
117
+ ⚠ SUTURES IDENTIFIED (2):
118
+ 🟡 Line 18 [LILITH] : Nested loop (depth 2). Consider a helper function.
119
+ >> for j in range(b):
120
+ 🔵 Line 67 [SOUVERAINETE] : 'load_data' receives 6 arguments. Encapsulate in an object.
121
+ >> def load_data(path, sep, enc, cols, dtype, na):
122
+ ```
123
+
124
+ ---
125
+
126
+ ## 🚀 CI Innovation Suite (Open Source)
127
+
128
+ `phi-complexity` embarque maintenant une suite orientée productivité/dev/ops :
129
+
130
+ - **AI AutoFix Studio** : règles de mutation déterministes pour appliquer rapidement des corrections CI.
131
+ - **Flow Intelligence** : classification dédiée des annulations liées à la concurrence (`WORKFLOW_CONCURRENCY_CANCELLED`).
132
+ - **Runner Sentinel** : détection explicite des blocages de queue runner (`RUNNER_QUEUE_STALL`).
133
+ - **Ops & Engineering Control Plane** : snapshot exportable JSON/Markdown (succès/échecs/cancelled, MTTR, causes racines, tendances).
134
+ - **Dev Productivity Environment** : `.devcontainer` + `Makefile` + commande `make ci-local` pour reproduire le pipeline localement.
135
+
136
+ ```bash
137
+ make setup
138
+ make ci-local
139
+ ```
140
+
141
+ ---
142
+
143
+ ## 🧮 Mathematical Foundations
144
+
145
+ The **Radiance Formula** is derived from:
146
+
147
+ - **φ-Meta Framework** (Tomy Verreault, 2026) — Axioms AX-A0 through AX-A58
148
+ - **Law of Antifragility** (EQ-AFR-BMAD): `φ_{t+1} = P_φ(φ_t + k·Var(E_t)·E_t)`
149
+ - **Cybernetics** (Korchounov, Mir, 1975) — Feedback and variance as control metrics
150
+ - **Shannon Information Theory** — Code as an information channel
151
+
152
+ The **Sovereign Coding Rules** are derived from:
153
+ - **The C Book** (Banahan, Brady, Doran) — Scope hermeticity, resource lifecycle
154
+ - **JaCaMo / Multi-Agent Programming** — Agent independence and encapsulation
155
+
156
+ Full mathematical proof: [docs/MATHEMATIQUES.md](https://github.com/spockoo/phi-complexity/blob/main/docs/MATHEMATIQUES.md)
157
+
158
+ ---
159
+
160
+ ## 🏗 Sovereign Architecture
161
+
162
+ ```
163
+ Zero external dependencies.
164
+ Pure Python standard library (ast, math, json).
165
+ ```
166
+
167
+ ```
168
+ phi_complexity/
169
+ ├── core.py ← Golden constants (PHI, TAXE_SUTURE, ETA_GOLDEN...)
170
+ ├── analyseur.py ← AST fractal dissection
171
+ ├── metriques.py ← Radiance Index calculation
172
+ ├── rapport.py ← Console / Markdown / JSON rendering
173
+ └── cli.py ← phi check / phi report
174
+ ```
175
+
176
+ ---
177
+
178
+ ## 🔗 Integration
179
+
180
+ ### Pre-commit Hook
181
+ ```yaml
182
+ repos:
183
+ - repo: https://github.com/spockoo/phi-complexity
184
+ rev: v0.1.0
185
+ hooks:
186
+ - id: phi-check
187
+ args: [--min-radiance, "70"]
188
+ ```
189
+
190
+ ### GitHub Action
191
+ ```yaml
192
+ - name: Phi-Complexity Audit
193
+ run: |
194
+ pip install phi-complexity
195
+ phi check ./src/ --min-radiance 75
196
+ ```
197
+
198
+ ### Secrets (`ADMIN_TOKEN`)
199
+
200
+ - Never commit `ADMIN_TOKEN` in tracked files.
201
+ - Store it in environment variables or GitHub Actions Secrets.
202
+ - Use `.env.example` as a template only:
203
+
204
+ ```dotenv
205
+ ADMIN_TOKEN=
206
+ ```
207
+
208
+ ---
209
+
210
+ ## 📜 License
211
+
212
+ MIT — Tomy Verreault, 2026
213
+
214
+ *Anchored in the Bibliothèque Céleste — Morphic Phi Framework (φ-Meta)*
215
+
216
+ ## 🔒 Sécurité : Activation du contrôle phi-check
217
+
218
+ 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).
219
+
220
+ **Pour installer et activer le contrôle localement :**
221
+ ```sh
222
+ pip install pre-commit
223
+ pre-commit install
224
+ ```
225
+ Le contrôle `phi-check` se lance alors automatiquement à chaque commit.
@@ -0,0 +1,100 @@
1
+ from __future__ import annotations
2
+ from typing import Dict, Any, Optional
3
+ from .core import PHI, TAXE_SUTURE, ETA_GOLDEN, VERSION, AUTEUR
4
+ from .analyseur import AnalyseurPhi
5
+ from .metriques import CalculateurRadiance
6
+ from .rapport import GenerateurRapport
7
+ from .suture import SutureAgent
8
+ from .oracle import OracleRadiance
9
+ from .harvest import HarvestEngine
10
+ from .vault import PhiVault
11
+ from .canvas import PhiCanvas
12
+ from .search import PhiSearch
13
+ from .fingerprint import FingerprintEngine, PhiFingerprint, similitude_cosinus
14
+
15
+
16
+ def auditer(fichier: str) -> Dict[str, Any]:
17
+ """
18
+ Lance un audit complet sur un fichier Python.
19
+ Retourne un dictionnaire de métriques.
20
+
21
+ Usage:
22
+ from phi_complexity import auditer
23
+ result = auditer("mon_script.py")
24
+ print(result["radiance"]) # → 82.4
25
+ """
26
+ analyseur: AnalyseurPhi = AnalyseurPhi(fichier)
27
+ resultat = analyseur.analyser()
28
+ calculateur: CalculateurRadiance = CalculateurRadiance(resultat)
29
+ return calculateur.calculer()
30
+
31
+
32
+ def rapport_console(fichier: str) -> str:
33
+ """Retourne le rapport ASCII formaté pour le terminal."""
34
+ metriques = auditer(fichier)
35
+ return GenerateurRapport(metriques).console()
36
+
37
+
38
+ def rapport_markdown(fichier: str, sortie: Optional[str] = None) -> str:
39
+ """
40
+ Génère un rapport Markdown.
41
+ Si `sortie` est spécifié, sauvegarde dans ce fichier.
42
+ Retourne le contenu Markdown.
43
+ """
44
+ metriques: Dict[str, Any] = auditer(fichier)
45
+ gen: GenerateurRapport = GenerateurRapport(metriques)
46
+ if sortie:
47
+ gen.sauvegarder_markdown(sortie)
48
+ return gen.markdown()
49
+
50
+
51
+ def rapport_json(fichier: str) -> str:
52
+ """Retourne le rapport JSON pour CI/CD."""
53
+ metriques = auditer(fichier)
54
+ return GenerateurRapport(metriques).json()
55
+
56
+
57
+ def suture(fichier: str, api_url: Optional[str] = None) -> str:
58
+ """
59
+ Invoque Phidélia pour proposer une suture du fichier.
60
+ Retourne la suggestion de l'IA (Markdown).
61
+ """
62
+ from .analyseur import AnalyseurPhi
63
+ from .metriques import CalculateurRadiance
64
+
65
+ analyseur = AnalyseurPhi(fichier)
66
+ resultat = analyseur.analyser()
67
+
68
+ # On injecte les métriques de radiance dans le résultat pour Phidélia
69
+ calculateur = CalculateurRadiance(resultat)
70
+ metriques = calculateur.calculer()
71
+ resultat.radiance = metriques["radiance"]
72
+
73
+ agent = SutureAgent(api_url) if api_url else SutureAgent()
74
+ return agent.suturer(resultat)
75
+
76
+
77
+ __version__ = VERSION
78
+ __author__ = AUTEUR
79
+ __all__ = [
80
+ "auditer",
81
+ "rapport_console",
82
+ "rapport_markdown",
83
+ "rapport_json",
84
+ "PHI",
85
+ "TAXE_SUTURE",
86
+ "ETA_GOLDEN",
87
+ "AnalyseurPhi",
88
+ "CalculateurRadiance",
89
+ "GenerateurRapport",
90
+ "SutureAgent",
91
+ "OracleRadiance",
92
+ "HarvestEngine",
93
+ "PhiVault",
94
+ "PhiCanvas",
95
+ "PhiSearch",
96
+ "FingerprintEngine",
97
+ "PhiFingerprint",
98
+ "similitude_cosinus",
99
+ "suture",
100
+ ]
@@ -1,3 +1,5 @@
1
- """Point d'entrée pour python -m phi_complexity"""
2
- from phi_complexity.cli import main
3
- main()
1
+ """Point d'entrée pour python -m phi_complexity"""
2
+
3
+ from phi_complexity.cli import main
4
+
5
+ main()