How khanhnam-nathan/pyneat works
1. Repository shape
This is a multi-language code analysis and cleanup platform centered on a Python package (pyneat/) with an optional Rust accelerator (pyneat-rs/). Around that core are IDE integrations, CLI entrypoints, security tooling, benchmarks, tests, and CI/CD workflows.
2. Primary product boundary: Python package
The main user-facing engine lives in pyneat/. It exposes the CLI (pyneat/cli.py, pyneat/__main__.py), configuration loading (config.py, config_loader.py), the rule engine (core/engine.py), and the rule catalog under pyneat/rules/. This is the default runtime for scan/clean operations and the Python API.
3. Core processing pipeline
The key flow is: source file or code string → parsing/normalization in pyneat/core and pyneat/scanner → rule evaluation from pyneat/rules → issue reporting and optional autofix → manifest/report export or in-place rewrite. The core package contains transformation safety boundaries such as atomic updates, scope/semantic guards, cleanup of markers, and type-related protections.
4. Rule system architecture
Rules are organized by concern, not by language alone. pyneat/rules/safe.py, conservative.py, destructive.py, quality.py, security.py, and the language-specific subpackages (go/, java/, javascript/, php/, ruby/, rust/, csharp/, multilang/) define the scanning and fixing logic. Supporting files like registry.py and security_registry.py indicate centralized discovery/selection of rules and security severities.
5. Security scanning as a first-class subsystem
Security functionality is not a thin addon; it is a parallel subsystem with its own rule packs (security_pack/), taint analysis (taint_analysis.py), secret classification, advisory integration, and vulnerability scanners under pyneat/tools/security/. The tests under tests/test_security/ show coverage for common OWASP-style issues plus AI-specific risks.
6. Reporting and export boundary
Output is standardized for downstream tools through report/manifest generation. The README references JSON, SARIF, HTML, Code Climate, and JUnit exports, while the repo includes manifest/export and marker cleanup support in pyneat/core/manifest.py and marker_cleanup.py. This boundary is what lets CI, GitHub code scanning, and editor integrations consume results consistently.
7. Rust backend (pyneat-rs)
The Rust crate is a performance-oriented alternate engine that mirrors the Python product domain. It contains its own scanner, rule engine, fixer, SARIF writer, and LSP server. Important architectural pieces include tree-sitter parsing, an LN-AST abstraction (ln_ast.rs, ln_ast_converter.rs), multi-language scanners under src/scanner/, and language-specific rule sets under src/rules/.
8. Cross-language scanning model in Rust
pyneat-rs is structured around language adapters for Python, JavaScript, TypeScript, Go, Java, PHP, Ruby, Rust, C#, and a multilang layer. Each adapter owns parsing and rule application for its language, while shared infrastructure in scanner/base.rs, rules/base.rs, and scanner/multilang.rs enables common behavior across languages.
9. Editor and IDE integrations
There are three separate integration surfaces: a VSCode/Cursor extension under vscode-extension/, a JetBrains plugin under jetbrains-plugin/, and a Neovim LSP client wrapper under nvim-lsp/. These do not implement analysis themselves; they call into the backend, render diagnostics, offer quick fixes, and expose context actions. The VSCode extension also includes a wrapper around the CLI/backend and a sidebar/context-provider model.
10. External integrations and ecosystem connectors
The Rust backend includes native integrations for GitHub, GitLab, and SonarQube under pyneat-rs/src/integrations/. The Python side also has security-oriented tooling under pyneat/tools/ for SBOM generation, OSV advisory lookup, dependency scanning, and GitHub fuzzing. These pieces sit at the edges of the system and feed security intelligence into scans or reports.
11. Validation, testing, and quality gates
The repo is heavily test-driven: Python tests cover engine behavior, rule behavior, integrations, fuzzing, marker cleanup, manifest export, multilang support, and security cases; Rust has integration tests and benches. Benchmarks exist on both sides, which matters architecturally because performance is a tracked feature, not just an implementation detail.
12. Build, release, and governance layer
GitHub Actions and GitLab CI workflows handle build, publish, security scans, benchmarks, and releases. The presence of pre-commit hooks, packaging files, changelog/release docs, and dual Python/Rust build artifacts shows a distribution architecture that supports both library use and installed CLI/editor tooling.
13. How the pieces fit together
The main architectural boundary is between “analysis logic” and “consumers.” Analysis logic lives in Python and Rust engines; consumers are CLI, Python API, IDE plugins, and CI integrations. Data typically enters as source text or files, is parsed into language-aware structures, transformed into findings/fixes, then emitted as patches, diagnostics, or standardized reports.
Main entry points: engine.py Engine · scanner Rust scanner · ci.yml CI/CD · tests Tests
Components 22
Python package
Primary analysis engine, rules, scanners, and tools exposed to users and automation.
- CLI · Command-line entrypoint and package launcher for scan/clean workflows.
pyneat/cli.py - Config · Loads and normalizes runtime configuration and options.
pyneat/config.py - Engine · Coordinates parsing, rule evaluation, fixes, and output generation.
pyneat/core/engine.py - Guards · Atomic updates, scope/semantic protections, type shielding, and marker cleanup.
pyneat/core - Reports · Manifest and standardized report emission for downstream tools.
pyneat/core/manifest.py - Scanner · Python-side scanner adapter and language-aware preprocessing.
pyneat/scanner - Rules · Central rule registry plus quality, security, and language-specific rule packs.
pyneat/rules - Security · Taint analysis, secret classification, advisory lookup, and vulnerability tooling.
pyneat/rules/taint_analysis.py - Plugins · Builtin plugin surface for extending or customizing analysis behavior.
pyneat/plugins - Tools · SBOM, OSV, dependency scanning, and GitHub fuzzing helpers.
pyneat/tools
Rust accelerator
Optional high-performance backend mirroring the analysis domain in Rust.
- Rust CLI · Rust crate entrypoint for the accelerator and standalone usage.
pyneat-rs/src/main.rs - Rust scanner · Tree-sitter-based scanning pipeline with LN-AST conversion and multilang adapters.
pyneat-rs/src/scanner - Rust rules · Shared Rust rule engine plus language and security rule sets.
pyneat-rs/src/rules - Fixer · Applies fixes and computes diffs for rewritten source.
pyneat-rs/src/fixer - SARIF · Produces standardized SARIF output from Rust analysis results.
pyneat-rs/src/sarif - Integrations · GitHub, GitLab, and SonarQube integration layer.
pyneat-rs/src/integrations
Integrations
Editor, IDE, and LSP entrypoints that consume analysis results.
- VS Code · Extension UI, diagnostics, fixes, and backend wrapper for VS Code/Cursor.
vscode-extension/src/extension.ts - JetBrains · Kotlin plugin providing inspections, dialogs, actions, and window integration.
jetbrains-plugin/src/main/kotlin/dev/pyneat/PyNEATInspection.kt - Neovim · Neovim wrapper that connects to the backend over LSP.
nvim-lsp/pyneat_lsp.lua
Quality gate
Tests, benchmarks, and CI/release workflows that validate and ship the platform.
- Tests · Python and Rust test suites covering engine, rules, security, multilang, and integration behavior.
tests - Benchmarks · Benchmark suites tracking parsing, batch processing, scanner, and rule performance.
benchmarks - CI/CD · GitHub Actions, GitLab, pre-commit, and release workflows.
.github/workflows/ci.yml
Connections 27
- CLI → Config: loads · CLI initializes runtime options and settings.
- CLI → Engine: invokes · CLI drives the main analysis pipeline.
- Engine → Scanner: parses · Engine delegates source intake and normalization to scanner layers.
- Engine → Rules: evaluates · Engine applies the rule catalog to discovered code patterns.
- Engine → Guards: protects · Core safety boundaries guard rewrites and transformations.
- Engine → Reports: emits · Engine exports standardized findings and manifests.
- Rules → Security: includes · Security pack is a first-class subset of the rule system.
- Rules → Plugins: extends · Plugin layer can add or adapt rule behavior.
- Security → Tools: feeds · Security tooling enriches scanning with advisories and dependency intelligence.
- Rust CLI → Rust scanner: drives · Rust entrypoint starts the parsing and scanning pipeline.
- Rust scanner → Rust rules: applies · Scanner evaluates rules over parsed language structures.
- Rust scanner → Fixer: rewrites · Findings can be turned into automated fixes and diffs.
- Rust rules → SARIF: exports · Rust results can be serialized to SARIF.
- Rust rules → Integrations: publishes · Integration layer consumes results for external platforms.
- VS Code → CLI: wraps · VS Code extension shells out to or coordinates with the Python backend.
- VS Code → Reports: reads · Extension consumes standardized diagnostics and outputs.
- JetBrains → Engine: calls · JetBrains plugin uses backend analysis for inspections and actions.
- Neovim → CLI: connects · Neovim client talks to the backend through LSP-facing entrypoints.
- Tests → Engine: verifies · Tests cover core engine behavior and rule application.
- Tests → Security: verifies · Security suites validate taint, secrets, and vulnerability rules.
- Tests → Rust scanner: verifies · Rust and Python tests exercise scanner parity and behavior.
- Benchmarks → Engine: measures · Benchmarks track Python-side processing performance.
- Benchmarks → Rust scanner: measures · Benchmarks track Rust-side parsing and scanning throughput.
- CI/CD → Tests: runs · CI executes validation gates before release.
- CI/CD → Benchmarks: tracks · Performance workflows monitor regressions.
- CI/CD → VS Code: packages · Release workflows build editor artifacts.
- CI/CD → Rust CLI: builds · CI produces Rust binaries and release artifacts.