pycheck-neuron 1.0.1__tar.gz → 1.0.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 (22) hide show
  1. {pycheck_neuron-1.0.1/pycheck_neuron.egg-info → pycheck_neuron-1.0.3}/PKG-INFO +56 -20
  2. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/README.md +294 -258
  3. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/pycheck/__init__.py +1 -1
  4. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/pycheck/analyzer.py +3 -2
  5. pycheck_neuron-1.0.3/pycheck/audit.py +153 -0
  6. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/pycheck/cli.py +31 -8
  7. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/pycheck/rules.py +96 -2
  8. pycheck_neuron-1.0.3/pycheck/server.py +201 -0
  9. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3/pycheck_neuron.egg-info}/PKG-INFO +56 -20
  10. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/pycheck_neuron.egg-info/SOURCES.txt +3 -0
  11. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/pyproject.toml +66 -66
  12. pycheck_neuron-1.0.3/tests/test_audit.py +49 -0
  13. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/tests/test_cli.py +85 -85
  14. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/tests/test_rules.py +30 -1
  15. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/LICENSE +0 -0
  16. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/pycheck/__main__.py +0 -0
  17. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/pycheck/flow.py +0 -0
  18. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/pycheck_neuron.egg-info/dependency_links.txt +0 -0
  19. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/pycheck_neuron.egg-info/entry_points.txt +0 -0
  20. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/pycheck_neuron.egg-info/requires.txt +0 -0
  21. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/pycheck_neuron.egg-info/top_level.txt +0 -0
  22. {pycheck_neuron-1.0.1 → pycheck_neuron-1.0.3}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycheck-neuron
3
- Version: 1.0.1
4
- Summary: 32-rule static AST analyzer catching temporal lookahead bias, causal confusion, and uncertainty bugs in Python ML code. Zero dependencies.
3
+ Version: 1.0.3
4
+ Summary: 33-rule static AST analyzer catching temporal lookahead bias, causal confusion, and uncertainty bugs in Python ML code. Zero dependencies.
5
5
  Author: NEURON Team
6
6
  Author-email: Fayo Ibrahim <fayo@neuron-lab.org>
7
7
  License-Expression: MIT
@@ -38,7 +38,7 @@ Dynamic: license-file
38
38
 
39
39
  # PyCheck — ML Safety Analyzer
40
40
 
41
- **30 rules. Zero dependencies. Catches the bugs that cost millions.**
41
+ **33 rules. Zero dependencies. Catches the bugs that cost millions.**
42
42
 
43
43
  PyCheck is a static AST analyzer that detects **temporal lookahead bias**, **causal confusion**, and **unguarded uncertainty** in Python ML and trading scripts — before you run a single line of code.
44
44
 
@@ -68,7 +68,7 @@ PyCheck catches all three before execution:
68
68
  =================================================================
69
69
  PyCheck — NEURON ML Safety Analyzer
70
70
  Scanning: strategy.py
71
- Rules: 30 active
71
+ Rules: 33 active + Data Flow & Provenance Engine
72
72
  =================================================================
73
73
 
74
74
  ERROR[T001]: .shift(-1) accesses data 1 rows INTO THE FUTURE
@@ -100,7 +100,7 @@ PyCheck catches all three before execution:
100
100
 
101
101
  ## What It Catches
102
102
 
103
- ### Temporal Leak Rules (17 rules — `T001`–`T017`)
103
+ ### Temporal Leak Rules (18 rules — `T001`–`T018`)
104
104
 
105
105
  | Rule | What It Catches | Severity |
106
106
  |------|----------------|----------|
@@ -121,6 +121,7 @@ PyCheck catches all three before execution:
121
121
  | `T015` | Negative `.shift()` inside `groupby().transform()` | **Error** |
122
122
  | `T016` | `pd.merge_asof()` with `direction='nearest'` or `'forward'` | **Error** |
123
123
  | `T017` | Target laundering & un-split target encoding (`regime_success_rate`) | **Error** |
124
+ | `T018` | In-sample target encoding (`groupby().transform('mean')`, `TargetEncoder(cv=None)`) | **Error** |
124
125
 
125
126
  ### Causal Confusion Rules (7 rules — `C001`–`C007`)
126
127
 
@@ -154,17 +155,30 @@ PyCheck catches all three before execution:
154
155
 
155
156
  ---
156
157
 
157
- ## Taint Flow Analysis
158
+ ## Data Flow & Provenance Tracking Engine
158
159
 
159
- Beyond pattern matching, PyCheck traces how future-contaminated data **flows through your codebase**:
160
+ Beyond syntactic pattern matching, PyCheck includes a two-pass AST data flow engine that traces data lineage across reassignments, aliases, joins, and helper functions:
160
161
 
162
+ ### 1. Future Taint Propagation (`F001`)
163
+ Traces future-leaked signals across multi-level variable indirection:
161
164
  ```python
162
- future_ret = df['close'].shift(-1) # Tainted source
163
- signal = future_ret - df['close'] # Taint propagates
164
- model.fit(X, signal) # ERROR: tainted label reaches .fit() sink
165
+ future_ret = df['close'].shift(-1) # Future taint source
166
+ signal = future_ret - df['close'] # Taint propagates through arithmetic
167
+ model.fit(X, signal) # ERROR[F001]: tainted data reaches .fit() sink
165
168
  ```
166
169
 
167
- The taint engine follows assignments across three levels of variable indirection.
170
+ ### 2. Partition Provenance & Contamination (`F002`)
171
+ Identifies training partitions, test partitions, and cross-fold leakage:
172
+ ```python
173
+ # Naming conventions alone are insufficient when variables get reassigned:
174
+ X_train = pd.concat([X_train, X_test]) # Tainted with test fold data
175
+ scaler.fit_transform(X_train) # ERROR[F002]: test partition data in training sink
176
+ ```
177
+
178
+ PyCheck follows:
179
+ - **Concatenation & Merges**: `pd.concat`, `np.concatenate`, `.append()`, `.merge()`, `.join()`.
180
+ - **Aliases**: `X_eval = X_test` followed by combination or fitting.
181
+ - **Inter-Procedural Helper Functions**: Functions returning expressions derived from test partition arguments.
168
182
 
169
183
  ---
170
184
 
@@ -175,7 +189,7 @@ pycheck script.py # Errors + warnings (default)
175
189
  pycheck script.py --info # Include info-level diagnostics
176
190
  pycheck script.py --quiet # Errors only
177
191
  pycheck script.py --json # JSON output — pipe into CI/CD
178
- pycheck --list # List all 30 rules
192
+ pycheck --list # List all 33 rules
179
193
  pycheck --help
180
194
  ```
181
195
 
@@ -269,21 +283,43 @@ The `pycheck-vscode` extension gives you **real-time red/yellow squiggles** as y
269
283
 
270
284
  ---
271
285
 
272
- ## Beyond Python: the NEURON Language
286
+ ---
287
+
288
+ ## Automated CI/CD Gatekeeping & Invariant Verification
289
+
290
+ For quant teams, machine learning desks, and algorithmic trading funds, **PyCheck** provides continuous compliance and automated gatekeeping:
291
+
292
+ * **Automated PR / MR Gatekeeping**: GitHub App & GitLab integration that automatically blocks pull requests containing temporal leaks, lookahead joins, or cross-fold contamination before they reach production.
293
+ * **Proof-of-Causality Audit Certificates**: Cryptographically verifiable backtest audit reports (PDF & JSON) certifying that quantitative strategies and feature pipelines are provably free of temporal lookahead bias for LP allocators and risk committees.
294
+ * **Firm-Wide Policy Engine**: Author proprietary firm-specific invariants, restrict internal data feed schemas, and monitor leak incident trends across 50+ quant researchers.
295
+ * **Air-Gapped & On-Prem Deployment**: Private VPC and on-premise Kubernetes support for proprietary trading strategies that cannot leave your internal network.
296
+
297
+ > See the [Enterprise CI/CD Integration](#enterprise-cicd--gitlab-integration) section or visit [https://github.com/neuronlabs-ai/pycheck](https://github.com/neuronlabs-ai/pycheck) to learn more or request institutional access.
298
+
299
+ ---
300
+
301
+ ## PyCheck & NEURON: Working Hand-in-Hand
273
302
 
274
- PyCheck catches these bugs **after you write them**.
303
+ PyCheck and the **[NEURON Programming Language](https://github.com/neuronlabs-ai/neuron-lang)** represent a dual-defense ecosystem against algorithmic failures:
275
304
 
276
- [NEURON](https://github.com/neuronlabs-ai/neuron-lang) prevents them **before the program compiles** — by encoding time horizons, causal modes, and uncertainty directly into the type system:
305
+ | System | Role | Mechanism | Guarantee |
306
+ | :--- | :--- | :--- | :--- |
307
+ | **PyCheck** | **The Diagnostic Layer** for existing Python code | 2-pass AST data flow & provenance static analysis | Flags known leakage patterns & contamination in seconds |
308
+ | **NEURON** | **The Permanent Cure** for future algorithmic systems | Type-theoretic stochastic filtration proofs ($\mathcal{F}_t$) | **100% mathematical compile-time proof**; zero runtime overhead |
277
309
 
310
+ ### The Migration Pathway
311
+ 1. **Audit Today with PyCheck**: Run `pycheck` across existing Python/Pandas/PyTorch repositories to identify lookahead leaks and target laundering.
312
+ 2. **Transpile with `py2nr`**: Use the automated transpiler to convert validated feature pipelines into typed NEURON modules.
313
+ 3. **Deploy with 100% Compile-Time Safety**:
278
314
  ```python
279
- # In NEURON, this is a compile-time error — not a runtime surprise:
315
+ # In NEURON, lookahead bias is a compile-time type error — not a runtime surprise:
280
316
  fn strategy(prices: Temporal[Tensor, 0]) -> Tensor:
281
- let future = prices.shift(-1)
282
- # error[TemporalLeak]: shift(-1) produces offset +1 > 0
283
- # Lookahead bias detected at compile time.
317
+ let future = prices.shift(1) # NEURON uses causal algebraic offsets (+1 is future)
318
+ # error[TemporalLeak]: operation requires filtration F_{t+1}, but context is F_t (offset 0)
319
+ # Lookahead bias rejected at compile time before execution.
284
320
  ```
285
321
 
286
- For 100% compile-time temporal proofs, type-checked do-calculus, and native ahead-of-time compilation, see the [NEURON language](https://github.com/neuronlabs-ai/neuron-lang).
322
+ Explore the language: [https://github.com/neuronlabs-ai/neuron-lang](https://github.com/neuronlabs-ai/neuron-lang)
287
323
 
288
324
  ---
289
325